diff mbox series

[linux-next] net: wwan: iosm: use kmemdup instead of kzalloc and memcpy

Message ID 20210917094241.232168-1-deng.changcheng@zte.com.cn (mailing list archive)
State Not Applicable
Delegated to: Netdev Maintainers
Headers show
Series [linux-next] net: wwan: iosm: use kmemdup instead of kzalloc and memcpy | expand

Checks

Context Check Description
netdev/tree_selection success Guessing tree name failed - patch did not apply

Commit Message

CGEL Sept. 17, 2021, 9:42 a.m. UTC
From: Changcheng Deng <deng.changcheng@zte.com.cn>

Fixes coccicheck warning: WARNING opportunity for kmemdup
in "./drivers/net/wwan/iosm/iosm_ipc_flash.c"

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Changcheng Deng <deng.changcheng@zte.com.cn>
---
 drivers/net/wwan/iosm/iosm_ipc_flash.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/drivers/net/wwan/iosm/iosm_ipc_flash.c b/drivers/net/wwan/iosm/iosm_ipc_flash.c
index a43aafc70168..3d2f1ec6da00 100644
--- a/drivers/net/wwan/iosm/iosm_ipc_flash.c
+++ b/drivers/net/wwan/iosm/iosm_ipc_flash.c
@@ -430,11 +430,10 @@  int ipc_flash_boot_psi(struct iosm_devlink *ipc_devlink,
 	int ret;
 
 	dev_dbg(ipc_devlink->dev, "Boot transfer PSI");
-	psi_code = kzalloc(fw->size, GFP_KERNEL);
+	psi_code = kmemdup(fw->data, fw->size, GFP_KERNEL);
 	if (!psi_code)
 		return -ENOMEM;
 
-	memcpy(psi_code, fw->data, fw->size);
 	ret = ipc_imem_sys_devlink_write(ipc_devlink, psi_code, fw->size);
 	if (ret) {
 		dev_err(ipc_devlink->dev, "RPSI Image write failed");