]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.14.60/net-hns3-fixes-the-out-of-bounds-access-in-hclge_map_tqp.patch
Fixes for 5.10
[thirdparty/kernel/stable-queue.git] / releases / 4.14.60 / net-hns3-fixes-the-out-of-bounds-access-in-hclge_map_tqp.patch
CommitLineData
a65d4bac
GKH
1From foo@baz Sat Jul 28 10:25:26 CEST 2018
2From: Huazhong Tan <tanhuazhong@huawei.com>
3Date: Tue, 1 May 2018 19:55:59 +0100
4Subject: net: hns3: Fixes the out of bounds access in hclge_map_tqp
5
6From: Huazhong Tan <tanhuazhong@huawei.com>
7
8[ Upstream commit 38e62046d4c95272e2fb001d2d72baf48fa090e9 ]
9
10This patch fixes the handling of the check when number of vports
11are detected to be more than available TPQs. Current handling causes
12an out of bounds access in hclge_map_tqp().
13
14Fixes: 7df7dad633e2 ("net: hns3: Refactor the mapping of tqp to vport")
15Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
16Signed-off-by: Peng Li <lipeng321@huawei.com>
17Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
18Signed-off-by: David S. Miller <davem@davemloft.net>
19Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
20Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
21---
22 drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 7 +++++--
23 1 file changed, 5 insertions(+), 2 deletions(-)
24
25--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
26+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
27@@ -1272,8 +1272,11 @@ static int hclge_alloc_vport(struct hclg
28 /* We need to alloc a vport for main NIC of PF */
29 num_vport = hdev->num_vmdq_vport + hdev->num_req_vfs + 1;
30
31- if (hdev->num_tqps < num_vport)
32- num_vport = hdev->num_tqps;
33+ if (hdev->num_tqps < num_vport) {
34+ dev_err(&hdev->pdev->dev, "tqps(%d) is less than vports(%d)",
35+ hdev->num_tqps, num_vport);
36+ return -EINVAL;
37+ }
38
39 /* Alloc the same number of TQPs for every vport */
40 tqp_per_vport = hdev->num_tqps / num_vport;