Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp2222228ybi; Thu, 4 Jul 2019 07:07:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqwJtHv3bZl3Ik68smJGmS9Bcrt3cx2AkGfkV+NuCrxbNtlzQEO93Q7BEoFeIquqi1vKhCte X-Received: by 2002:a63:3f48:: with SMTP id m69mr42844902pga.17.1562249245708; Thu, 04 Jul 2019 07:07:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562249245; cv=none; d=google.com; s=arc-20160816; b=LRk4B8ECCvede+um4ZukZrgdlTmdoiXgejS5OWxKam7/Hw0L92kIL5+pzCFaunh6qe ludSwH2E37lBPSF+bcpjkcTGhlJUTNOW69rRLdyDjSvjPJCe3Jv9KRXg5EViUwVjqe43 uj3liZhppPek1oLGGDPxxGp37CAupFgtV6RULYwuY6k4e5zbVhxOMoN4jKC42FqzoRFi plwhQPoGRY0weYIK6tHM+eNi7odiM4YjJf89mpEI2YoPbt34XcWiC1XQGleCTaRijETp Obs3RKkt/HAAvUZeecguRP3jVJj1y3WRsbSAteBBjZIZSCSuCv2nxAVrWZ6lV5tZOX9w 4vOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=rtDK1Tla1Y5BkvN4wrkhNTl1riwghyrN3SMYp/vjoYo=; b=seNiNlMCUIiYilpxQW13tseaSQ//YMWZHtJcgN5t0ELzvUTGSw1gKPPL8bvO7pDEYp 3jIlqw2T4naoxA6Xny8HPv7N0hU6IKQHvPFIlNWpErTstlCJ2RoLj1dS5RlCyBv2ABmk ys3USgz2ivc/lzo0+FVPMGwUCZlx9/d+TejM0mgqfw7tkL2Gd1qnWEY7U6diLsdz+gBg Jdn7DZcGNZiTnkoQ0pEy9vhGt251wed7LhZIZEXsKTEDnpaHK8g08opq7kjahaKQdoPi /Fp1XHSUYE9jzF9e+mx2pRIlwG5U36ibWAbfFtcVhf14Ba1U1jblHzcKZ1A06Z+T8Kzy wmLQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o4si5485687pgp.476.2019.07.04.07.07.10; Thu, 04 Jul 2019 07:07:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727574AbfGDOGj (ORCPT + 99 others); Thu, 4 Jul 2019 10:06:39 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:8705 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727494AbfGDOGg (ORCPT ); Thu, 4 Jul 2019 10:06:36 -0400 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 0FC7B1EBFB885B41CCCE; Thu, 4 Jul 2019 22:06:27 +0800 (CST) Received: from localhost.localdomain (10.67.212.132) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.439.0; Thu, 4 Jul 2019 22:06:17 +0800 From: Huazhong Tan To: CC: , , , , , Weihang Li , Peng Li , Huazhong Tan Subject: [PATCH net-next 6/9] net: hns3: check msg_data before memcpy in hclgevf_send_mbx_msg Date: Thu, 4 Jul 2019 22:04:25 +0800 Message-ID: <1562249068-40176-7-git-send-email-tanhuazhong@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1562249068-40176-1-git-send-email-tanhuazhong@huawei.com> References: <1562249068-40176-1-git-send-email-tanhuazhong@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.67.212.132] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Weihang Li 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 Signed-off-by: Peng Li Signed-off-by: Huazhong Tan --- drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c index 30f2e93..f60b80b 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) { -- 2.7.4