Skip to content

Commit 86db7bf

Browse files
Peiyang WangPaolo Abeni
authored andcommitted
net: hns3: void array out of bound when loop tnl_num
When query reg inf of SSU, it loops tnl_num times. However, tnl_num comes from hardware and the length of array is a fixed value. To void array out of bound, make sure the loop time is not greater than the length of array Signed-off-by: Peiyang Wang <[email protected]> Signed-off-by: Jijie Shao <[email protected]> Signed-off-by: Paolo Abeni <[email protected]>
1 parent be5e816 commit 86db7bf

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1598,8 +1598,7 @@ static void hclge_query_reg_info_of_ssu(struct hclge_dev *hdev)
15981598
{
15991599
u32 loop_para[HCLGE_MOD_MSG_PARA_ARRAY_MAX_SIZE] = {0};
16001600
struct hclge_mod_reg_common_msg msg;
1601-
u8 i, j, num;
1602-
u32 loop_time;
1601+
u8 i, j, num, loop_time;
16031602

16041603
num = ARRAY_SIZE(hclge_ssu_reg_common_msg);
16051604
for (i = 0; i < num; i++) {
@@ -1609,7 +1608,8 @@ static void hclge_query_reg_info_of_ssu(struct hclge_dev *hdev)
16091608
loop_time = 1;
16101609
loop_para[0] = 0;
16111610
if (msg.need_para) {
1612-
loop_time = hdev->ae_dev->dev_specs.tnl_num;
1611+
loop_time = min(hdev->ae_dev->dev_specs.tnl_num,
1612+
HCLGE_MOD_MSG_PARA_ARRAY_MAX_SIZE);
16131613
for (j = 0; j < loop_time; j++)
16141614
loop_para[j] = j + 1;
16151615
}

0 commit comments

Comments
 (0)