OSDN Git Service

net: hns3: check msg_data before memcpy in hclgevf_send_mbx_msg
authorWeihang Li <liweihang@hisilicon.com>
Thu, 4 Jul 2019 14:04:25 +0000 (22:04 +0800)
committerDavid S. Miller <davem@davemloft.net>
Fri, 5 Jul 2019 22:39:38 +0000 (15:39 -0700)
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>
drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c

index 30f2e93..f60b80b 100644 (file)
@@ -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) {