public inbox for linux-wireless@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] wifi: rtw89: 8852b: avoid reporting errors by cppcheck
@ 2024-01-10  4:17 Li Lin Mao
  2024-01-10  5:48 ` Ping-Ke Shih
  0 siblings, 1 reply; 4+ messages in thread
From: Li Lin Mao @ 2024-01-10  4:17 UTC (permalink / raw)
  To: linux-wireless; +Cc: pkshih, kvalo, Li Lin Mao

Due to some reasons in cppcheck, the following issues might be reported:
drivers/net/wireless/realtek/rtw89/rtw8852b_rfk.c:1414:22: error: Array
 'iqk_info->iqk_mcc_ch[2][4]' accessed at index iqk_info->iqk_mcc_ch[2][*],
which is out of bounds. [arrayIndexOutOfBounds]
 iqk_info->iqk_mcc_ch[idx][path] = chan->channel;
                     ^
drivers/net/wireless/realtek/rtw89/rtw8852b_rfk.c:1393:2: note: After for
loop, idx has value 2
 for (idx = 0; idx < RTW89_IQK_CHS_NR; idx++) {
 ^
drivers/net/wireless/realtek/rtw89/rtw8852b_rfk.c:1414:22: note: Array index
out of bounds
 iqk_info->iqk_mcc_ch[idx][path] = chan->channel;
                     ^
drivers/net/wireless/realtek/rtw89/rtw8852b_rfk.c:1424:38: error: Array
'iqk_info->iqk_mcc_ch[2][4]' accessed at index iqk_info->iqk_mcc_ch[2][*],
which is out of bounds. [arrayIndexOutOfBounds]
      idx, path, iqk_info->iqk_mcc_ch[idx][path]);
                                     ^
drivers/net/wireless/realtek/rtw89/rtw8852b_rfk.c:1393:2: note: After for
loop, idx has value 2
 for (idx = 0; idx < RTW89_IQK_CHS_NR; idx++) {
 ^
drivers/net/wireless/realtek/rtw89/rtw8852b_rfk.c:1424:38: note: Array index
out of bounds
      idx, path, iqk_info->iqk_mcc_ch[idx][path]);
                                     ^
But actually this might be a false alarm. We avoided it in some way.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Li Lin Mao <lilinmao@kylinos.cn>
---
 drivers/net/wireless/realtek/rtw89/rtw8852b_rfk.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtw89/rtw8852b_rfk.c b/drivers/net/wireless/realtek/rtw89/rtw8852b_rfk.c
index 259df67836a0..03169287667c 100644
--- a/drivers/net/wireless/realtek/rtw89/rtw8852b_rfk.c
+++ b/drivers/net/wireless/realtek/rtw89/rtw8852b_rfk.c
@@ -1388,17 +1388,15 @@ static void _iqk_get_ch_info(struct rtw89_dev *rtwdev, enum rtw89_phy_idx phy, u
 	u32 reg_rf18;
 	u32 reg_35c;
 	u8 idx;
-	u8 get_empty_table = false;
 
 	for (idx = 0; idx < RTW89_IQK_CHS_NR; idx++) {
 		if (iqk_info->iqk_mcc_ch[idx][path] == 0) {
-			get_empty_table = true;
 			break;
 		}
 	}
 	rtw89_debug(rtwdev, RTW89_DBG_RFK, "[IQK] (1)idx = %x\n", idx);
 
-	if (!get_empty_table) {
+	if (idx >= RTW89_IQK_CHS_NR) {
 		idx = iqk_info->iqk_table_idx[path] + 1;
 		if (idx > 1)
 			idx = 0;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread
* [PATCH v2] wifi: rtw89: 8852b: avoid reporting errors by cppcheck
@ 2024-01-10  4:14 Li Lin Mao
  0 siblings, 0 replies; 4+ messages in thread
From: Li Lin Mao @ 2024-01-10  4:14 UTC (permalink / raw)
  To: linux-wireless; +Cc: pkshih, kvalo, Li Lin Mao

Due to some reasons in cppcheck, the following issues might be reported:
drivers/net/wireless/realtek/rtw89/rtw8852b_rfk.c:1414:22: error: Array
 'iqk_info->iqk_mcc_ch[2][4]' accessed at index iqk_info->iqk_mcc_ch[2][*],
which is out of bounds. [arrayIndexOutOfBounds]
 iqk_info->iqk_mcc_ch[idx][path] = chan->channel;
                     ^
drivers/net/wireless/realtek/rtw89/rtw8852b_rfk.c:1393:2: note: After for
loop, idx has value 2
 for (idx = 0; idx < RTW89_IQK_CHS_NR; idx++) {
 ^
drivers/net/wireless/realtek/rtw89/rtw8852b_rfk.c:1414:22: note: Array index
out of bounds
 iqk_info->iqk_mcc_ch[idx][path] = chan->channel;
                     ^
drivers/net/wireless/realtek/rtw89/rtw8852b_rfk.c:1424:38: error: Array
'iqk_info->iqk_mcc_ch[2][4]' accessed at index iqk_info->iqk_mcc_ch[2][*],
which is out of bounds. [arrayIndexOutOfBounds]
      idx, path, iqk_info->iqk_mcc_ch[idx][path]);
                                     ^
drivers/net/wireless/realtek/rtw89/rtw8852b_rfk.c:1393:2: note: After for
loop, idx has value 2
 for (idx = 0; idx < RTW89_IQK_CHS_NR; idx++) {
 ^
drivers/net/wireless/realtek/rtw89/rtw8852b_rfk.c:1424:38: note: Array index
out of bounds
      idx, path, iqk_info->iqk_mcc_ch[idx][path]);
                                     ^
But actually this might be a false alarm. We avoided it in some way.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Li Lin Mao <lilinmao@kylinos.cn>
---
 drivers/net/wireless/realtek/rtw89/rtw8852b_rfk.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtw89/rtw8852b_rfk.c b/drivers/net/wireless/realtek/rtw89/rtw8852b_rfk.c
index 259df67836a0..03169287667c 100644
--- a/drivers/net/wireless/realtek/rtw89/rtw8852b_rfk.c
+++ b/drivers/net/wireless/realtek/rtw89/rtw8852b_rfk.c
@@ -1388,17 +1388,15 @@ static void _iqk_get_ch_info(struct rtw89_dev *rtwdev, enum rtw89_phy_idx phy, u
 	u32 reg_rf18;
 	u32 reg_35c;
 	u8 idx;
-	u8 get_empty_table = false;
 
 	for (idx = 0; idx < RTW89_IQK_CHS_NR; idx++) {
 		if (iqk_info->iqk_mcc_ch[idx][path] == 0) {
-			get_empty_table = true;
 			break;
 		}
 	}
 	rtw89_debug(rtwdev, RTW89_DBG_RFK, "[IQK] (1)idx = %x\n", idx);
 
-	if (!get_empty_table) {
+	if (idx >= RTW89_IQK_CHS_NR) {
 		idx = iqk_info->iqk_table_idx[path] + 1;
 		if (idx > 1)
 			idx = 0;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread
* [PATCH v2] wifi: rtw89: 8852b: avoid reporting errors by cppcheck
@ 2024-01-10  4:12 Li Lin Mao
  0 siblings, 0 replies; 4+ messages in thread
From: Li Lin Mao @ 2024-01-10  4:12 UTC (permalink / raw)
  To: linux-wireless; +Cc: pkshih, kvalo, Li Lin Mao

Due to some reasons in cppcheck, the following issues might be reported:
drivers/net/wireless/realtek/rtw89/rtw8852b_rfk.c:1414:22: error: Array
 'iqk_info->iqk_mcc_ch[2][4]' accessed at index iqk_info->iqk_mcc_ch[2][*],
which is out of bounds. [arrayIndexOutOfBounds]
 iqk_info->iqk_mcc_ch[idx][path] = chan->channel;
                     ^
drivers/net/wireless/realtek/rtw89/rtw8852b_rfk.c:1393:2: note: After for
loop, idx has value 2
 for (idx = 0; idx < RTW89_IQK_CHS_NR; idx++) {
 ^
drivers/net/wireless/realtek/rtw89/rtw8852b_rfk.c:1414:22: note: Array index
out of bounds
 iqk_info->iqk_mcc_ch[idx][path] = chan->channel;
                     ^
drivers/net/wireless/realtek/rtw89/rtw8852b_rfk.c:1424:38: error: Array
'iqk_info->iqk_mcc_ch[2][4]' accessed at index iqk_info->iqk_mcc_ch[2][*],
which is out of bounds. [arrayIndexOutOfBounds]
      idx, path, iqk_info->iqk_mcc_ch[idx][path]);
                                     ^
drivers/net/wireless/realtek/rtw89/rtw8852b_rfk.c:1393:2: note: After for
loop, idx has value 2
 for (idx = 0; idx < RTW89_IQK_CHS_NR; idx++) {
 ^
drivers/net/wireless/realtek/rtw89/rtw8852b_rfk.c:1424:38: note: Array index
out of bounds
      idx, path, iqk_info->iqk_mcc_ch[idx][path]);
                                     ^
But actually this might be a false alarm. We avoided it in some way.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Li Lin Mao <lilinmao@kylinos.cn>
---
 drivers/net/wireless/realtek/rtw89/rtw8852b_rfk.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtw89/rtw8852b_rfk.c b/drivers/net/wireless/realtek/rtw89/rtw8852b_rfk.c
index 259df67836a0..03169287667c 100644
--- a/drivers/net/wireless/realtek/rtw89/rtw8852b_rfk.c
+++ b/drivers/net/wireless/realtek/rtw89/rtw8852b_rfk.c
@@ -1388,17 +1388,15 @@ static void _iqk_get_ch_info(struct rtw89_dev *rtwdev, enum rtw89_phy_idx phy, u
 	u32 reg_rf18;
 	u32 reg_35c;
 	u8 idx;
-	u8 get_empty_table = false;
 
 	for (idx = 0; idx < RTW89_IQK_CHS_NR; idx++) {
 		if (iqk_info->iqk_mcc_ch[idx][path] == 0) {
-			get_empty_table = true;
 			break;
 		}
 	}
 	rtw89_debug(rtwdev, RTW89_DBG_RFK, "[IQK] (1)idx = %x\n", idx);
 
-	if (!get_empty_table) {
+	if (idx >= RTW89_IQK_CHS_NR) {
 		idx = iqk_info->iqk_table_idx[path] + 1;
 		if (idx > 1)
 			idx = 0;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-01-10  5:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-10  4:17 [PATCH v2] wifi: rtw89: 8852b: avoid reporting errors by cppcheck Li Lin Mao
2024-01-10  5:48 ` Ping-Ke Shih
  -- strict thread matches above, loose matches on Subject: below --
2024-01-10  4:14 Li Lin Mao
2024-01-10  4:12 Li Lin Mao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox