* [PATCH -next] hinic: Use kmemdup instead of kzalloc and memcpy
@ 2020-04-29 3:35 Zou Wei
2020-05-01 3:59 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Zou Wei @ 2020-04-29 3:35 UTC (permalink / raw)
To: aviad.krawczyk, davem; +Cc: netdev, linux-kernel, Zou Wei
Fixes coccicheck warnings:
drivers/net/ethernet/huawei/hinic/hinic_hw_mbox.c:452:17-24: WARNING opportunity for kmemdup
drivers/net/ethernet/huawei/hinic/hinic_hw_mbox.c:458:23-30: WARNING opportunity for kmemdup
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Zou Wei <zou_wei@huawei.com>
---
drivers/net/ethernet/huawei/hinic/hinic_hw_mbox.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ethernet/huawei/hinic/hinic_hw_mbox.c b/drivers/net/ethernet/huawei/hinic/hinic_hw_mbox.c
index f8626df..a39cc16 100644
--- a/drivers/net/ethernet/huawei/hinic/hinic_hw_mbox.c
+++ b/drivers/net/ethernet/huawei/hinic/hinic_hw_mbox.c
@@ -449,18 +449,15 @@ static void recv_mbox_handler(struct hinic_mbox_func_to_func *func_to_func,
return;
}
- rcv_mbox_temp = kzalloc(sizeof(*rcv_mbox_temp), GFP_KERNEL);
+ rcv_mbox_temp = kmemdup(recv_mbox, sizeof(*rcv_mbox_temp), GFP_KERNEL);
if (!rcv_mbox_temp)
return;
- memcpy(rcv_mbox_temp, recv_mbox, sizeof(*rcv_mbox_temp));
-
- rcv_mbox_temp->mbox = kzalloc(MBOX_MAX_BUF_SZ, GFP_KERNEL);
+ rcv_mbox_temp->mbox = kmemdup(recv_mbox->mbox, MBOX_MAX_BUF_SZ,
+ GFP_KERNEL);
if (!rcv_mbox_temp->mbox)
goto err_alloc_rcv_mbox_msg;
- memcpy(rcv_mbox_temp->mbox, recv_mbox->mbox, MBOX_MAX_BUF_SZ);
-
rcv_mbox_temp->buf_out = kzalloc(MBOX_MAX_BUF_SZ, GFP_KERNEL);
if (!rcv_mbox_temp->buf_out)
goto err_alloc_rcv_mbox_buf;
--
2.6.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH -next] hinic: Use kmemdup instead of kzalloc and memcpy
2020-04-29 3:35 [PATCH -next] hinic: Use kmemdup instead of kzalloc and memcpy Zou Wei
@ 2020-05-01 3:59 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2020-05-01 3:59 UTC (permalink / raw)
To: zou_wei; +Cc: aviad.krawczyk, netdev, linux-kernel
From: Zou Wei <zou_wei@huawei.com>
Date: Wed, 29 Apr 2020 11:35:28 +0800
> Fixes coccicheck warnings:
>
> drivers/net/ethernet/huawei/hinic/hinic_hw_mbox.c:452:17-24: WARNING opportunity for kmemdup
> drivers/net/ethernet/huawei/hinic/hinic_hw_mbox.c:458:23-30: WARNING opportunity for kmemdup
>
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Zou Wei <zou_wei@huawei.com>
Applied.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-05-01 3:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-29 3:35 [PATCH -next] hinic: Use kmemdup instead of kzalloc and memcpy Zou Wei
2020-05-01 3:59 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).