aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget/inode.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/gadget/inode.c')
-rw-r--r--drivers/usb/gadget/inode.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/drivers/usb/gadget/inode.c b/drivers/usb/gadget/inode.c
index b94c049ab0d0..b5be6f0308c2 100644
--- a/drivers/usb/gadget/inode.c
+++ b/drivers/usb/gadget/inode.c
@@ -439,11 +439,9 @@ ep_write (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
439 /* FIXME writebehind for O_NONBLOCK and poll(), qlen = 1 */ 439 /* FIXME writebehind for O_NONBLOCK and poll(), qlen = 1 */
440 440
441 value = -ENOMEM; 441 value = -ENOMEM;
442 kbuf = kmalloc (len, GFP_KERNEL); 442 kbuf = memdup_user(buf, len);
443 if (!kbuf) 443 if (!kbuf) {
444 goto free1; 444 value = PTR_ERR(kbuf);
445 if (copy_from_user (kbuf, buf, len)) {
446 value = -EFAULT;
447 goto free1; 445 goto free1;
448 } 446 }
449 447
@@ -452,7 +450,6 @@ ep_write (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
452 data->name, len, (int) value); 450 data->name, len, (int) value);
453free1: 451free1:
454 mutex_unlock(&data->lock); 452 mutex_unlock(&data->lock);
455 kfree (kbuf);
456 return value; 453 return value;
457} 454}
458 455