Commit 3b74c73f8d6f053f422e85fce955b61fb181cfe7
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>
Showing 1 changed file with 3 additions and 6 deletions Side-by-side Diff
... | ... | @@ -439,12 +439,10 @@ |
439 | 439 | /* FIXME writebehind for O_NONBLOCK and poll(), qlen = 1 */ |
440 | 440 | |
441 | 441 | value = -ENOMEM; |
442 | - kbuf = kmalloc (len, GFP_KERNEL); | |
443 | - if (!kbuf) | |
442 | + kbuf = memdup_user(buf, len); | |
443 | + if (!kbuf) { | |
444 | + value = PTR_ERR(kbuf); | |
444 | 445 | goto free1; |
445 | - if (copy_from_user (kbuf, buf, len)) { | |
446 | - value = -EFAULT; | |
447 | - goto free1; | |
448 | 446 | } |
449 | 447 | |
450 | 448 | value = ep_io (data, kbuf, len); |
... | ... | @@ -452,7 +450,6 @@ |
452 | 450 | data->name, len, (int) value); |
453 | 451 | free1: |
454 | 452 | mutex_unlock(&data->lock); |
455 | - kfree (kbuf); | |
456 | 453 | return value; |
457 | 454 | } |
458 | 455 |
-
mentioned in commit 100a00
-
mentioned in commit 100a00
-
mentioned in commit 100a00
-
mentioned in commit 100a00
-
mentioned in commit 100a00
-
mentioned in commit b44be2
-
mentioned in commit b44be2
-
mentioned in commit b44be2
-
mentioned in commit b44be2
-
mentioned in commit b44be2
-
mentioned in commit b44be2
-
mentioned in commit b44be2
-
mentioned in commit b44be2
-
mentioned in commit b44be2
-
mentioned in commit b44be2
-
mentioned in commit b44be2
-
mentioned in commit b44be2
-
mentioned in commit b44be2
-
mentioned in commit b44be2
-
mentioned in commit b44be2
-
mentioned in commit b44be2
-
mentioned in commit b44be2
-
mentioned in commit b44be2
-
mentioned in commit b44be2
-
mentioned in commit b44be2
-
mentioned in commit b44be2
-
mentioned in commit b44be2
-
mentioned in commit b44be2
-
mentioned in commit b44be2
-
mentioned in commit b44be2
-
mentioned in commit b44be2