提交 58b949e0 编写于 作者: B Benoit Taine 提交者: Felipe Balbi

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: NBenoit Taine <benoit.taine@lip6.fr>
Signed-off-by: NFelipe Balbi <balbi@ti.com>
上级 eac44dc4
...@@ -1021,12 +1021,10 @@ static ssize_t ext_prop_data_store(struct usb_os_desc_ext_prop *ext_prop, ...@@ -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') if (page[len - 1] == '\n' || page[len - 1] == '\0')
--len; --len;
new_data = kzalloc(len, GFP_KERNEL); new_data = kmemdup(page, len, GFP_KERNEL);
if (!new_data) if (!new_data)
return -ENOMEM; return -ENOMEM;
memcpy(new_data, page, len);
if (desc->opts_mutex) if (desc->opts_mutex)
mutex_lock(desc->opts_mutex); mutex_lock(desc->opts_mutex);
kfree(ext_prop->data); kfree(ext_prop->data);
......
...@@ -3045,11 +3045,10 @@ static int __init lpc32xx_udc_probe(struct platform_device *pdev) ...@@ -3045,11 +3045,10 @@ static int __init lpc32xx_udc_probe(struct platform_device *pdev)
dma_addr_t dma_handle; dma_addr_t dma_handle;
struct device_node *isp1301_node; struct device_node *isp1301_node;
udc = kzalloc(sizeof(*udc), GFP_KERNEL); udc = kmemdup(&controller_template, sizeof(*udc), GFP_KERNEL);
if (!udc) if (!udc)
return -ENOMEM; return -ENOMEM;
memcpy(udc, &controller_template, sizeof(*udc));
for (i = 0; i <= 15; i++) for (i = 0; i <= 15; i++)
udc->ep[i].udc = udc; udc->ep[i].udc = udc;
udc->gadget.ep0 = &udc->ep[0].ep; udc->gadget.ep0 = &udc->ep[0].ep;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册