aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c
diff options
context:
space:
mode:
authorWeihang Li <liweihang@hisilicon.com>2019-07-04 22:04:25 +0800
committerDavid S. Miller <davem@davemloft.net>2019-07-05 15:39:38 -0700
commit0bae5cf25d66156ae3eb9ca20a1ad9bc4aa35a6d (patch)
treed17509d3eaeacd2b8b0b5ba17a8ec8fcd4e78610 /drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c
parentnet: hns3: set default value for param "type" in hclgevf_bind_ring_to_vector (diff)
downloadlinux-dev-0bae5cf25d66156ae3eb9ca20a1ad9bc4aa35a6d.tar.xz
linux-dev-0bae5cf25d66156ae3eb9ca20a1ad9bc4aa35a6d.zip
net: hns3: check msg_data before memcpy in hclgevf_send_mbx_msg
The value of msg_data may be NULL in some cases, which will cause errors reported by some compiler. So this patch adds a check to fix it. Signed-off-by: Weihang Li <liweihang@hisilicon.com> Signed-off-by: Peng Li <lipeng321@huawei.com> Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to '')
-rw-r--r--drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c
index 30f2e9352cf3..f60b80bd605e 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c
@@ -102,7 +102,8 @@ int hclgevf_send_mbx_msg(struct hclgevf_dev *hdev, u16 code, u16 subcode,
~HCLGE_MBX_NEED_RESP_BIT;
req->msg[0] = code;
req->msg[1] = subcode;
- memcpy(&req->msg[2], msg_data, msg_len);
+ if (msg_data)
+ memcpy(&req->msg[2], msg_data, msg_len);
/* synchronous send */
if (need_resp) {