Commit 3b74c73f authored by Felipe Balbi's avatar Felipe Balbi Committed by Greg Kroah-Hartman

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: default avatarFelipe Balbi <balbi@ti.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent f3c73649
...@@ -439,11 +439,9 @@ ep_write (struct file *fd, const char __user *buf, size_t len, loff_t *ptr) ...@@ -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 */ /* FIXME writebehind for O_NONBLOCK and poll(), qlen = 1 */
value = -ENOMEM; value = -ENOMEM;
kbuf = kmalloc (len, GFP_KERNEL); kbuf = memdup_user(buf, len);
if (!kbuf) if (!kbuf) {
goto free1; value = PTR_ERR(kbuf);
if (copy_from_user (kbuf, buf, len)) {
value = -EFAULT;
goto free1; goto free1;
} }
...@@ -452,7 +450,6 @@ ep_write (struct file *fd, const char __user *buf, size_t len, loff_t *ptr) ...@@ -452,7 +450,6 @@ ep_write (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
data->name, len, (int) value); data->name, len, (int) value);
free1: free1:
mutex_unlock(&data->lock); mutex_unlock(&data->lock);
kfree (kbuf);
return value; return value;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment