hikptool/0080-hikptool-nic-Fix-potential-dead-loop.patch
zhangyuyang 9266dc4f4d hikptool: Modify the review comments to increase the reliability of the code
Synchronize code, Modify the review comments to increase the reliability of the code

Signed-off-by: veega2022 <zhuweijia@huawei.com>
(cherry picked from commit d2a23f9ffed0201385c7864b9cd58312fb395cb6)
2024-11-26 16:32:40 +08:00

44 lines
1.4 KiB
Diff

From c89df2898b19f1a1503bd41c065aa163a1900b53 Mon Sep 17 00:00:00 2001
From: Jie Hai <haijie1@huawei.com>
Date: Thu, 29 Aug 2024 10:08:55 +0800
Subject: [PATCH 18/27] hikptool/nic: Fix potential dead loop
When the loop variable range does not cover the upper bound
of the loop, an infinite loop occurs. This patch fixes it.
Signed-off-by: Jie Hai <haijie1@huawei.com>
---
net/nic/nic_fd/hikp_nic_fd.c | 2 +-
net/nic/nic_ppp/hikp_nic_ppp.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/nic/nic_fd/hikp_nic_fd.c b/net/nic/nic_fd/hikp_nic_fd.c
index 3d6a9dc..7125699 100644
--- a/net/nic/nic_fd/hikp_nic_fd.c
+++ b/net/nic/nic_fd/hikp_nic_fd.c
@@ -503,7 +503,7 @@ static void hikp_nic_show_fd_rules(const void *data)
struct nic_fd_rule_info *rule;
uint16_t max_key_bytes;
size_t one_rule_size;
- uint16_t i;
+ uint32_t i;
key_cfg = &g_fd_hw_info.key_cfg[stage_no];
stage_rules = &rules[stage_no];
diff --git a/net/nic/nic_ppp/hikp_nic_ppp.c b/net/nic/nic_ppp/hikp_nic_ppp.c
index 96f317b..67a3be6 100644
--- a/net/nic/nic_ppp/hikp_nic_ppp.c
+++ b/net/nic/nic_ppp/hikp_nic_ppp.c
@@ -184,7 +184,7 @@ static void hikp_nic_ppp_show_func_uc_mac_addr(struct mac_vlan_uc_tbl *uc_tbl,
struct mac_vlan_uc_entry *uc_entry;
uint8_t pf_id;
uint8_t vf_id;
- uint8_t i;
+ uint32_t i;
for (i = 0; i < uc_tbl->entry_size; i++) {
uc_entry = &uc_tbl->entry[i];
--
2.45.0.windows.1