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>
This commit is contained in:

committed by
Felipe Balbi

parent
eac44dc4e7
commit
58b949e084
@@ -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);
|
||||
|
Reference in New Issue
Block a user