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

From: cgel . zte
Date: Fri Sep 17 2021 - 05:43:38 EST


From: Changcheng Deng <deng.changcheng@xxxxxxxxxx>

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

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

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");
--
2.25.1