summaryrefslogtreecommitdiff
path: root/drivers/usb/misc/iowarrior.c
diff options
context:
space:
mode:
authorGeliang Tang <geliangtang@gmail.com>2017-05-13 06:16:00 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-05-17 13:20:54 +0300
commitca2ef0d5cd0568d4ef60da6ff6bd7f69f317407a (patch)
tree5eeb4a9314c62cd63d24462431c333075f5e96a7 /drivers/usb/misc/iowarrior.c
parent2aa3add0cc8f4b937062f33332297486c95ae966 (diff)
downloadlinux-ca2ef0d5cd0568d4ef60da6ff6bd7f69f317407a.tar.xz
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>
Diffstat (limited to 'drivers/usb/misc/iowarrior.c')
-rw-r--r--drivers/usb/misc/iowarrior.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/drivers/usb/misc/iowarrior.c b/drivers/usb/misc/iowarrior.c
index 77569531b78a..816afadc4707 100644
--- a/drivers/usb/misc/iowarrior.c
+++ b/drivers/usb/misc/iowarrior.c
@@ -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);