diff options
author | Benoit Taine <benoit.taine@lip6.fr> | 2014-05-26 17:21:20 +0200 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2014-06-30 19:27:09 +0200 |
commit | 58b949e0842a4751eec77edd60bd6178cef5b8de (patch) | |
tree | 009a5f34d67216a11f306e13b6d7ab8abdd3063f /drivers/usb/gadget/configfs.c | |
parent | usb: musb: musb_host.c: Cleaning up uninitialized variables (diff) | |
download | linux-58b949e0842a4751eec77edd60bd6178cef5b8de.tar.xz linux-58b949e0842a4751eec77edd60bd6178cef5b8de.zip |
usb: gadget: Use kmemdup instead of kmalloc + memcpy
This issue was reported by coccicheck using the semantic patch
at scripts/coccinelle/api/memdup.cocci
Signed-off-by: Benoit Taine <benoit.taine@lip6.fr>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/gadget/configfs.c')
-rw-r--r-- | drivers/usb/gadget/configfs.c | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c index 2ddcd635ca2a..bcc2a6248187 100644 --- a/drivers/usb/gadget/configfs.c +++ b/drivers/usb/gadget/configfs.c @@ -1021,12 +1021,10 @@ static ssize_t ext_prop_data_store(struct usb_os_desc_ext_prop *ext_prop, if (page[len - 1] == '\n' || page[len - 1] == '\0') --len; - new_data = kzalloc(len, GFP_KERNEL); + new_data = kmemdup(page, len, GFP_KERNEL); if (!new_data) return -ENOMEM; - memcpy(new_data, page, len); - if (desc->opts_mutex) mutex_lock(desc->opts_mutex); kfree(ext_prop->data); |