rtw89: avoid stringop-overflow warning
PATCH 1/1 rtw89: avoid stringop-overflow warning
From: Arnd Bergmann <[email protected]>
After -Wstringop-overflow got enabled, the rtw89 driver produced two odd warnings with gcc-13:
drivers/net/wireless/realtek/rtw89/coex.c: In function 'rtw89_btc_ntfy_scan_start':drivers/net/wireless/realtek/rtw89/coex.c:5362:50: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=]
5362 | wl->dbcc_info.scan_band[phy_idx] = band;
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~In file included from drivers/net/wireless/realtek/rtw89/coex.h:8,
from drivers/net/wireless/realtek/rtw89/coex.c:5:drivers/net/wireless/realtek/rtw89/core.h:1441:12: note: at offset [64, 255] into destination object 'scan_band' of size 2
1441 | u8 scan_band[RTW89_PHY_MAX]; /* scan band in each phy */
| ^~~~~~~~~
drivers/net/wireless/realtek/rtw89/coex.c: In function 'rtw89_btc_ntfy_switch_band':
drivers/net/wireless/realtek/rtw89/coex.c:5406:50: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=]
5406 | wl->dbcc_info.scan_band[phy_idx] = band;
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
drivers/net/wireless/realtek/rtw89/core.h:1441:12: note: at offset [64, 255] into destination object 'scan_band' of size 2
1441 | u8 scan_band[RTW89_PHY_MAX]; /* scan band in each phy */
| ^~~~~~~~~I don't know what happened here, but adding an explicit range check shuts up the output.
--- drivers/net/wireless/realtek/rtw89/coex.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/net/wireless/realtek/rtw89/coex.c +8 -0
@@ -5352,6 +5352,10 @@ void rtw89_btc_ntfy_scan_start(struct rtw89_dev *rtwdev, u8 phy_idx, u8 band)rtw89_debug (rtwdev,RTW89_DBG_BTC ,"[BTC], %s(): phy_idx=%d, band=%d\n" , __func__, phy_idx, band); + +if (phy_idx >=RTW89_PHY_MAX ) +return ; + btc->dm.cnt_notify[BTC_NCNT_SCAN_START ]++; wl->status.map.scan = true; wl->scan_info.band[phy_idx] = band;
@@ -5396,6 +5400,10 @@ void rtw89_btc_ntfy_switch_band(struct rtw89_dev *rtwdev, u8 phy_idx, u8 band)rtw89_debug (rtwdev,RTW89_DBG_BTC ,"[BTC], %s(): phy_idx=%d, band=%d\n" , __func__, phy_idx, band); + +if (phy_idx >=RTW89_PHY_MAX ) +return ; + btc->dm.cnt_notify[BTC_NCNT_SWITCH_BAND ]++; wl->scan_info.band[phy_idx] = band;
Signature · 1 line
2.39.2
Ping-Ke Shih
maintainerQuoted 10 lines
-----Original Message-----
From: Arnd Bergmann <[email protected]>
Sent: Monday, December 4, 2023 3:30 PM
To: Ping-Ke Shih <[email protected]>; Kalle Valo <[email protected]>; Gustavo A. R. Silva <[email protected]>
Cc: Arnd Bergmann <[email protected]>; DeanKu <[email protected]>; [email protected]; [email protected]
Subject: [PATCH] rtw89: avoid stringop-overflow warning
Subject prefix should be "wifi: rtw89: ..."
Quoted 27 lines
From: Arnd Bergmann <[email protected]>
After -Wstringop-overflow got enabled, the rtw89 driver produced two odd warnings with gcc-13:
drivers/net/wireless/realtek/rtw89/coex.c: In function 'rtw89_btc_ntfy_scan_start':drivers/net/wireless/realtek/rtw89/coex.c:5362:50: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=]5362 | wl->dbcc_info.scan_band[phy_idx] = band; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~In file included from
drivers/net/wireless/realtek/rtw89/coex.h:8,
fromdrivers/net/wireless/realtek/rtw89/coex.c:5:drivers/net/wireless/realtek/rtw89/core.h:1441:12: note: at offset [64, 255] into destination object 'scan_band' of size 2
1441 | u8 scan_band[RTW89_PHY_MAX]; /* scan band in each phy */| ^~~~~~~~~ drivers/net/wireless/realtek/rtw89/coex.c: In function 'rtw89_btc_ntfy_switch_band': drivers/net/wireless/realtek/rtw89/coex.c:5406:50: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=] 5406 | wl->dbcc_info.scan_band[phy_idx] = band; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~ drivers/net/wireless/realtek/rtw89/core.h:1441:12: note: at offset [64, 255] into destination object 'scan_band' of size 2 1441 | u8 scan_band[RTW89_PHY_MAX]; /* scan band in each phy */ | ^~~~~~~~~
Quoted 2 lines
I don't know what happened here, but adding an explicit range check shuts up the output.
The callers of these two cases will pass RTW89_PHY_0 (0) as argument of phy_idx, and will extend to pass RTW89_PHY_1 (1) in the future, but should not be larger than 1.
I don't mind to add this checking, but I really don't know what happened neither. A statement 'wl->scan_info.band[phy_idx] = band;' did similar thing in the same function, but why doesn't gcc complain this?
Quoted 22 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
After -Wstringop-overflow got enabled, the rtw89 driver produced two odd warnings with gcc-13:
drivers/net/wireless/realtek/rtw89/coex.c: In function 'rtw89_btc_ntfy_scan_start':drivers/net/wireless/realtek/rtw89/coex.c:5362:50: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=]5362 | wl->dbcc_info.scan_band[phy_idx] = band; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~In file included from
drivers/net/wireless/realtek/rtw89/coex.h:8,
fromdrivers/net/wireless/realtek/rtw89/coex.c:5:drivers/net/wireless/realtek/rtw89/core.h:1441:12: note: at offset [64, 255] into destination object 'scan_band' of size 2
1441 | u8 scan_band[RTW89_PHY_MAX]; /* scan band in each phy */| ^~~~~~~~~ drivers/net/wireless/realtek/rtw89/coex.c: In function 'rtw89_btc_ntfy_switch_band': drivers/net/wireless/realtek/rtw89/coex.c:5406:50: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=] 5406 | wl->dbcc_info.scan_band[phy_idx] = band; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~ drivers/net/wireless/realtek/rtw89/core.h:1441:12: note: at offset [64, 255] into destination object 'scan_band' of size 2 1441 | u8 scan_band[RTW89_PHY_MAX]; /* scan band in each phy */ | ^~~~~~~~~
Quoted 5 lines
I don't know what happened here, but adding an explicit range check shuts up the output.
Fixes 89741e7e42f6 ("Makefile: Enable -Wstringop-overflow globally")Signed-off-by Arnd Bergmann <[email protected]>
ERROR: 'wifi:' prefix missing: '[PATCH] rtw89: avoid stringop-overflow warning'
ERROR: Failed to find commit id: Fixes: 89741e7e42f6 ("Makefile: Enable -Wstringop-overflow globally")
I can add the "wifi:" prefix but where can I find the commit 89741e7e42f6?
Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
Quoted 6 lines · Kalle Valo
Quoted 4 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
Fixes 89741e7e42f6 ("Makefile: Enable -Wstringop-overflow globally")Signed-off-by Arnd Bergmann <[email protected]>
Quoted 6 lines
ERROR: 'wifi:' prefix missing: '[PATCH] rtw89: avoid stringop-overflow warning'
ERROR: Failed to find commit id: Fixes:89741e7e42f6("Makefile: Enable -Wstringop-overflow globally")I can add the "wifi:" prefix but where can I find the commit
89741e7e42f6?
It's in linux-next and came in from Gustavo's tree at
https://git.kernel.org/pub/scm/linux/kernel/git/gustavoars/linux.git/log/?h=for-next/kspp
Arnd
Quoted 12 lines · Arnd Bergmann
Quoted 11 lines · Kalle Valo
Quoted 4 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
Fixes 89741e7e42f6 ("Makefile: Enable -Wstringop-overflow globally")Signed-off-by Arnd Bergmann <[email protected]>ERROR: 'wifi:' prefix missing: '[PATCH] rtw89: avoid stringop-overflow warning'
ERROR: Failed to find commit id: Fixes:89741e7e42f6("Makefile: Enable -Wstringop-overflow globally")
Quoted 4 lines
Quoted 1 line
I can add the "wifi:" prefix but where can I find the commit
89741e7e42f6?It's in linux-next and came in from Gustavo's tree at
https://git.kernel.org/pub/scm/linux/kernel/git/gustavoars/linux.git/log/?h=for-next/kspp
Ah, I think then I'll drop the Fixes tag to avoid warnings or reports. My understanding is that a commit in the Fixes tag should be a parent.
Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/list/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
Re: wifi: rtw89: avoid stringop-overflow warning
In reply to Arnd BergmannQuoted 22 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
After -Wstringop-overflow got enabled, the rtw89 driver produced two odd warnings with gcc-13:
drivers/net/wireless/realtek/rtw89/coex.c: In function 'rtw89_btc_ntfy_scan_start':drivers/net/wireless/realtek/rtw89/coex.c:5362:50: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=]5362 | wl->dbcc_info.scan_band[phy_idx] = band; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~In file included from
drivers/net/wireless/realtek/rtw89/coex.h:8,
fromdrivers/net/wireless/realtek/rtw89/coex.c:5:drivers/net/wireless/realtek/rtw89/core.h:1441:12: note: at offset [64, 255] into destination object 'scan_band' of size 2
1441 | u8 scan_band[RTW89_PHY_MAX]; /* scan band in each phy */| ^~~~~~~~~ drivers/net/wireless/realtek/rtw89/coex.c: In function 'rtw89_btc_ntfy_switch_band': drivers/net/wireless/realtek/rtw89/coex.c:5406:50: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=] 5406 | wl->dbcc_info.scan_band[phy_idx] = band; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~ drivers/net/wireless/realtek/rtw89/core.h:1441:12: note: at offset [64, 255] into destination object 'scan_band' of size 2 1441 | u8 scan_band[RTW89_PHY_MAX]; /* scan band in each phy */ | ^~~~~~~~~
Quoted 4 lines
I don't know what happened here, but adding an explicit range check shuts up the output.
Signed-off-by Arnd Bergmann <[email protected]>
Patch applied to wireless-next.git, thanks.
595b1280e2c9 wifi: rtw89: avoid stringop-overflow warning
Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches