]>
Commit | Line | Data |
---|---|---|
a65d4bac GKH |
1 | From foo@baz Sat Jul 28 10:25:26 CEST 2018 |
2 | From: Huazhong Tan <tanhuazhong@huawei.com> | |
3 | Date: Tue, 1 May 2018 19:55:59 +0100 | |
4 | Subject: net: hns3: Fixes the out of bounds access in hclge_map_tqp | |
5 | ||
6 | From: Huazhong Tan <tanhuazhong@huawei.com> | |
7 | ||
8 | [ Upstream commit 38e62046d4c95272e2fb001d2d72baf48fa090e9 ] | |
9 | ||
10 | This patch fixes the handling of the check when number of vports | |
11 | are detected to be more than available TPQs. Current handling causes | |
12 | an out of bounds access in hclge_map_tqp(). | |
13 | ||
14 | Fixes: 7df7dad633e2 ("net: hns3: Refactor the mapping of tqp to vport") | |
15 | Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com> | |
16 | Signed-off-by: Peng Li <lipeng321@huawei.com> | |
17 | Signed-off-by: Salil Mehta <salil.mehta@huawei.com> | |
18 | Signed-off-by: David S. Miller <davem@davemloft.net> | |
19 | Signed-off-by: Sasha Levin <alexander.levin@microsoft.com> | |
20 | Signed-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; |