Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp2222745ybi; Thu, 4 Jul 2019 07:07:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqxxm30SdCbdBiqOFVYLWZGiO++aNIQ3iuOF2R5bo4VMifjRoYL1ashgQniysda6Ajl0D1T4 X-Received: by 2002:a63:f941:: with SMTP id q1mr1026891pgk.350.1562249272280; Thu, 04 Jul 2019 07:07:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562249272; cv=none; d=google.com; s=arc-20160816; b=dKdIdNYGAicMPKbOj4O2gjmxBh2gwX809l3cCU2T/9O1YfjUIHrgZ28yG6yTW+PPPs NGzCtN/dJn/P9V+Yk97ayCxh/Ziq5mhwejbAkcmy+pvJNwfe9v2Q92eKmP5ecB89aQUV rNq3cFC1+WYrGPHMgWhPsN3kUfO4c7ieu5hMrIhFr33mq/BGwcbJR907mGSRJn52FUca p+0c4E9qraKRTuwT/Y00H5uBH1tG9wi8XGUFNc3DtThd7DESaFRPaCr1Cj2KKEfvSXXy 6aZs5Hzllw9M1K8K5Q+C/q5UTP+oe390D3alstr9gGWTgiD9axGjJs6tJi3AOI6Wek/g RVmQ== 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=2ZxosNji19si7a8s8oPLM7sGH3Vj4OicVnBmXjz++vw=; b=dHqTqmHxJDpybRc7elAkO+Lrq2qLalWCYqhpB8BIKxtnInMNYslr+nzuoZq+n7PRoe oicoglvXBQrYKkpxg2jRcmBQHGabinWYpSb72tKghedXlX8VuJnTci88cNsXigM5uRgX 8a0j87Wy1LIScBXOrmd1x7wm4VISi783aiJjtWQ8U7t76JV04B31Xh/Rk1pP3U97pvQk svCGvyqKJ8HVEA95pkF/2Yymo7DGo7dOP/4AFjQF7QDmlGqefK2iSiChZ0y8fqhJ5FvG Yg2q6KC2l/e0w3hvuTnJEOavdY1AK1XWgAmEjTB5hjcv5wqBcAcQKeyGxOFNfzo1IeOG +4MQ== 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 10si6114718pgw.494.2019.07.04.07.07.37; Thu, 04 Jul 2019 07:07:52 -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 S1727459AbfGDOGd (ORCPT + 99 others); Thu, 4 Jul 2019 10:06:33 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:8703 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727363AbfGDOG3 (ORCPT ); Thu, 4 Jul 2019 10:06:29 -0400 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 035B7F141CD314A737D5; 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:18 +0800 From: Huazhong Tan To: CC: , , , , , Peng Li , Huazhong Tan Subject: [PATCH net-next 9/9] net: hns3: set maximum length to resp_data_len for exceptional case Date: Thu, 4 Jul 2019 22:04:28 +0800 Message-ID: <1562249068-40176-10-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: Peng Li If HCLGE_MBX_MAX_RESP_DATA_SIZE > HCLGE_MBX_MAX_RESP_DATA_SIZE, the memcpy will cause out of memory. So this patch just set resp_data_len to the maximum length for this case. Signed-off-by: Peng Li Signed-off-by: Huazhong Tan --- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c index 9adeba9..a38ac7c 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c @@ -29,6 +29,10 @@ static int hclge_gen_resp_to_vf(struct hclge_vport *vport, "PF fail to gen resp to VF len %d exceeds max len %d\n", resp_data_len, HCLGE_MBX_MAX_RESP_DATA_SIZE); + /* If resp_data_len is too long, set the value to max length + * and return the msg to VF + */ + resp_data_len = HCLGE_MBX_MAX_RESP_DATA_SIZE; } hclge_cmd_setup_basic_desc(&desc, HCLGEVF_OPC_MBX_PF_TO_VF, false); -- 2.7.4