]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
USB: iowarrior: use memdup_user
authorGeliang Tang <geliangtang@gmail.com>
Sat, 13 May 2017 03:16:00 +0000 (11:16 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 17 May 2017 10:20:54 +0000 (12:20 +0200)
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>
drivers/usb/misc/iowarrior.c

index 77569531b78a56d45fb43ee255a0a22e6da2979d..816afadc470729922c70dd63a2654b220b77e375 100644 (file)
@@ -368,14 +368,9 @@ static ssize_t iowarrior_write(struct file *file,
        case USB_DEVICE_ID_CODEMERCS_IOWPV2:
        case USB_DEVICE_ID_CODEMERCS_IOW40:
                /* IOW24 and IOW40 use a synchronous call */
-               buf = kmalloc(count, GFP_KERNEL);
-               if (!buf) {
-                       retval = -ENOMEM;
-                       goto exit;
-               }
-               if (copy_from_user(buf, user_buffer, count)) {
-                       retval = -EFAULT;
-                       kfree(buf);
+               buf = memdup_user(user_buffer, count);
+               if (IS_ERR(buf)) {
+                       retval = PTR_ERR(buf);
                        goto exit;
                }
                retval = usb_set_report(dev->interface, 2, 0, buf, count);