diff options
author | Felipe Balbi <balbi@ti.com> | 2014-03-10 19:30:55 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-03-18 00:05:31 +0100 |
commit | 3b74c73f8d6f053f422e85fce955b61fb181cfe7 (patch) | |
tree | 48b041492d61f35a8fbd66dfa1a4892b65a15802 /drivers/usb/gadget | |
parent | usb: gadget: f_subset: switch over to PTR_RET (diff) | |
download | linux-3b74c73f8d6f053f422e85fce955b61fb181cfe7.tar.xz linux-3b74c73f8d6f053f422e85fce955b61fb181cfe7.zip |
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/gadget')
-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) /* FIXME writebehind for O_NONBLOCK and poll(), qlen = 1 */ value = -ENOMEM; - kbuf = kmalloc (len, GFP_KERNEL); - if (!kbuf) - goto free1; - if (copy_from_user (kbuf, buf, len)) { - value = -EFAULT; + kbuf = memdup_user(buf, len); + if (!kbuf) { + value = PTR_ERR(kbuf); goto free1; } @@ -452,7 +450,6 @@ ep_write (struct file *fd, const char __user *buf, size_t len, loff_t *ptr) data->name, len, (int) value); free1: mutex_unlock(&data->lock); - kfree (kbuf); return value; } |