forked from luck/tmp_suning_uos_patched
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>
This commit is contained in:
parent
f3c7364982
commit
3b74c73f8d
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user