USB: iowarrior: use memdup_user
Use memdup_user() helper instead of open-coding to simplify the code. Signed-off-by: Geliang Tang <geliangtang@gmail.com> Reviewed-by: Johan Hovold <johan@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
2aa3add0cc
commit
ca2ef0d5cd
@@ -368,14 +368,9 @@ static ssize_t iowarrior_write(struct file *file,
|
|||||||
case USB_DEVICE_ID_CODEMERCS_IOWPV2:
|
case USB_DEVICE_ID_CODEMERCS_IOWPV2:
|
||||||
case USB_DEVICE_ID_CODEMERCS_IOW40:
|
case USB_DEVICE_ID_CODEMERCS_IOW40:
|
||||||
/* IOW24 and IOW40 use a synchronous call */
|
/* IOW24 and IOW40 use a synchronous call */
|
||||||
buf = kmalloc(count, GFP_KERNEL);
|
buf = memdup_user(user_buffer, count);
|
||||||
if (!buf) {
|
if (IS_ERR(buf)) {
|
||||||
retval = -ENOMEM;
|
retval = PTR_ERR(buf);
|
||||||
goto exit;
|
|
||||||
}
|
|
||||||
if (copy_from_user(buf, user_buffer, count)) {
|
|
||||||
retval = -EFAULT;
|
|
||||||
kfree(buf);
|
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
retval = usb_set_report(dev->interface, 2, 0, buf, count);
|
retval = usb_set_report(dev->interface, 2, 0, buf, count);
|
||||||
|
|||||||
Reference in New Issue
Block a user