Commit 37ecb5b8 authored by Zou Wei's avatar Zou Wei Committed by David S. Miller

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: default avatarHulk Robot <hulkci@huawei.com>
Signed-off-by: default avatarZou Wei <zou_wei@huawei.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 25979125
...@@ -449,18 +449,15 @@ static void recv_mbox_handler(struct hinic_mbox_func_to_func *func_to_func, ...@@ -449,18 +449,15 @@ static void recv_mbox_handler(struct hinic_mbox_func_to_func *func_to_func,
return; 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) if (!rcv_mbox_temp)
return; return;
memcpy(rcv_mbox_temp, recv_mbox, sizeof(*rcv_mbox_temp)); rcv_mbox_temp->mbox = kmemdup(recv_mbox->mbox, MBOX_MAX_BUF_SZ,
GFP_KERNEL);
rcv_mbox_temp->mbox = kzalloc(MBOX_MAX_BUF_SZ, GFP_KERNEL);
if (!rcv_mbox_temp->mbox) if (!rcv_mbox_temp->mbox)
goto err_alloc_rcv_mbox_msg; 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); rcv_mbox_temp->buf_out = kzalloc(MBOX_MAX_BUF_SZ, GFP_KERNEL);
if (!rcv_mbox_temp->buf_out) if (!rcv_mbox_temp->buf_out)
goto err_alloc_rcv_mbox_buf; goto err_alloc_rcv_mbox_buf;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment