Received: by 10.192.165.148 with SMTP id m20csp5272806imm; Tue, 1 May 2018 12:01:53 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpFFtCKMbN9xHjXf7MacHsT+8ldvmtyA3ZmwfUoNCKWJbUxt5fyqxxK7SknZd7SuvzLKXWx X-Received: by 2002:a17:902:30a3:: with SMTP id v32-v6mr17446027plb.123.1525201313192; Tue, 01 May 2018 12:01:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525201313; cv=none; d=google.com; s=arc-20160816; b=MMjvkCeM78zwRwuhtfkYkkzg9IlxZGOrR2vAsfqOq7My++FRgGPe8tdEZrPWz2MP2N 5C8nBzu0gXtuCBTSmVcKHQnZLuy4F+W5oVB20DIGfQOdtuzTjEhyJpyuG23SWuqUgv5V 1uS7fRg/35+usYHHPcYTTaG5WE1qpRyG0nsY/ogMQh85ZG5Evl30dAwgrNBOk9/IqUYX lVDCT2q0FJBpt68N3LBhQuqBUcDrOaRDgpQOaxk9exmp+QbnuA6yCnUbO3DUuNc+vM8a UJRsaYxqiN+qdxxAdnUc7OxTuZMtNI6mrxC6gbj7HTPjwIyBkELCT0DzyledFuhRnyCR JMNw== 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:arc-authentication-results; bh=mNRr40qhrJkA/zO5Ycc4HhzTUzhy9OiiMGFXc2b9jM8=; b=BfzcsSvisRO2dQXtW8Yyo1AeslcVT6r75Dip00rLDqhUmohQPHBEtlpW1GiM5xijHv m3y6ufvHkqrAZo9HX2TkEqQ+0x6xhkvP7B5g9jyiLJYmXJJIywCecZ0MAVIesWENYXZH d4W7Ng5rZDFHAwQWfZbiu7A4fyVDQpkOzYc5B3qnXXaVJnHN+kYCG96Nwc/kYIhOBvVZ Zp0hLlzWrVlXBkC22NYYoqw/K9jT3v7j12aKhq80X4WdWbM6RCj0f0ZnlSUfMJrdWMxF 2OWWtSdDoWhxSThP+QQfxPZIeGErQYBTKcfHVsWKFuA03Gww5opK4bCNlTZoZaXobFtH 59+w== 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 w18-v6si7688488pge.604.2018.05.01.12.01.38; Tue, 01 May 2018 12:01:53 -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 S1756502AbeEAS6C (ORCPT + 99 others); Tue, 1 May 2018 14:58:02 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:7640 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754790AbeEAS6A (ORCPT ); Tue, 1 May 2018 14:58:00 -0400 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 46FD65074A8F3; Wed, 2 May 2018 02:57:47 +0800 (CST) Received: from S00293818-DELL1.china.huawei.com (10.202.226.46) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.361.1; Wed, 2 May 2018 02:57:41 +0800 From: Salil Mehta To: CC: , , , , , , , Huazhong Tan Subject: [PATCH net-next 3/9] net: hns3: Fixes the out of bounds access in hclge_map_tqp Date: Tue, 1 May 2018 19:55:59 +0100 Message-ID: <20180501185605.9584-4-salil.mehta@huawei.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20180501185605.9584-1-salil.mehta@huawei.com> References: <20180501185605.9584-1-salil.mehta@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.202.226.46] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Huazhong Tan This patch fixes the handling of the check when number of vports are detected to be more than available TPQs. Current handling causes an out of bounds access in hclge_map_tqp(). Fixes: 7df7dad633e2 ("net: hns3: Refactor the mapping of tqp to vport") Signed-off-by: Huazhong Tan Signed-off-by: Peng Li Signed-off-by: Salil Mehta --- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 2066dd7..c9e80ca 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -1459,8 +1459,11 @@ static int hclge_alloc_vport(struct hclge_dev *hdev) /* We need to alloc a vport for main NIC of PF */ num_vport = hdev->num_vmdq_vport + hdev->num_req_vfs + 1; - if (hdev->num_tqps < num_vport) - num_vport = hdev->num_tqps; + if (hdev->num_tqps < num_vport) { + dev_err(&hdev->pdev->dev, "tqps(%d) is less than vports(%d)", + hdev->num_tqps, num_vport); + return -EINVAL; + } /* Alloc the same number of TQPs for every vport */ tqp_per_vport = hdev->num_tqps / num_vport; -- 2.7.4