summaryrefslogtreecommitdiff
path: root/drivers/gpib
diff options
context:
space:
mode:
authorMohammad Shahid <mdshahid03@gmail.com>2026-07-05 10:47:01 +0530
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2026-07-17 14:54:05 +0200
commit9d4ce1c7cd35f6333785d0ef1c3032f6ecb1a5b8 (patch)
treef89fc275a14cbcd4f335926818370f722fa60c48 /drivers/gpib
parenta168e2cfb741d81be3736dba6dbe5edc2295aacb (diff)
downloadlinux-next-9d4ce1c7cd35f6333785d0ef1c3032f6ecb1a5b8.tar.gz
linux-next-9d4ce1c7cd35f6333785d0ef1c3032f6ecb1a5b8.zip
gpib: lpvo_usb_gpib: use memdup_user() instead of kmalloc() and copy_from_user()
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 <mdshahid03@gmail.com> Link: https://patch.msgid.link/20260705051701.142070-1-mdshahid03@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/gpib')
-rw-r--r--drivers/gpib/lpvo_usb_gpib/lpvo_usb_gpib.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/drivers/gpib/lpvo_usb_gpib/lpvo_usb_gpib.c b/drivers/gpib/lpvo_usb_gpib/lpvo_usb_gpib.c
index 13a067010db7..dfb8f3ebc27f 100644
--- a/drivers/gpib/lpvo_usb_gpib/lpvo_usb_gpib.c
+++ b/drivers/gpib/lpvo_usb_gpib/lpvo_usb_gpib.c
@@ -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);