diff options
author | Zou Wei <zou_wei@huawei.com> | 2020-04-29 11:35:28 +0800 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2020-04-30 20:59:34 -0700 |
commit | 37ecb5b8b8cd3156e739fd1c56a8e3842b72ebad (patch) | |
tree | 21d62509a23f21fb8315087ceaa482aa175dbb37 /drivers/net | |
parent | 2597912514925f6f06e85807cc9fc0fdfa630d11 (diff) | |
download | linux-37ecb5b8b8cd3156e739fd1c56a8e3842b72ebad.tar.bz2 |
hinic: Use kmemdup instead of kzalloc and memcpy
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/ethernet/huawei/hinic/hinic_hw_mbox.c | 9 |
1 files 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 d5cf31529dbf..564fb2294a29 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; |