mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-09-18 23:09:29 +02:00
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>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
a168e2cfb7
commit
9d4ce1c7cd
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user