gpib: lpvo_usb_gpib: use memdup_user() instead of kmalloc() and copy_from_user()
PATCH 1/1 gpib: lpvo_usb_gpib: use memdup_user() instead of kmalloc() and copy_from_user()
From: Mohammad Shahid <[email protected]>
Use memdup_user() to replace the open-coded kmalloc() and copy_from_user() sequence.
This simplifies the code while preserving the existing behavior.
This issue was reported by memdup_user.cocci.
Signed-off-by Mohammad Shahid <[email protected]>
--- drivers/gpib/lpvo_usb_gpib/lpvo_usb_gpib.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-)
drivers/gpib/lpvo_usb_gpib/lpvo_usb_gpib.c +3 -8
@@ -1811,14 +1811,9 @@ static ssize_t lpvo_write(struct file *file, const char __user *user_buffer, dev = file->private_data; - buf =kmalloc (count,GFP_KERNEL ); -if (!buf) -return -ENOMEM ; - -if (copy_from_user (buf, user_buffer, count)) { -kfree (buf); -return -EFAULT ; - } + buf =memdup_user (user_buffer, count); +if (IS_ERR (buf)) +return PTR_ERR (buf); rv =lpvo_do_write (dev, buf, count);kfree (buf);
Signature · 1 line
2.43.0