diff options
author | Felipe Balbi <balbi@ti.com> | 2014-03-10 14:30:55 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-03-17 19:05:31 -0400 |
commit | 3b74c73f8d6f053f422e85fce955b61fb181cfe7 (patch) | |
tree | 48b041492d61f35a8fbd66dfa1a4892b65a15802 /drivers/usb | |
parent | f3c73649828397ca6bae88bcb8cd70bbcbb65b18 (diff) |
usb: gadget: inode: switch over to memdup_user()
This patch fixes the following Coccinelle warning:
drivers/usb/gadget/inode.c:442:8-15: WARNING \
opportunity for memdup_user
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb')
-rw-r--r-- | drivers/usb/gadget/inode.c | 9 |
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); |
453 | free1: | 451 | free1: |
454 | mutex_unlock(&data->lock); | 452 | mutex_unlock(&data->lock); |
455 | kfree (kbuf); | ||
456 | return value; | 453 | return value; |
457 | } | 454 | } |
458 | 455 | ||