wifi: rtw89: regd: avoid freeing devm-allocated 6 GHz band
PATCH 1/1 wifi: rtw89: regd: avoid freeing devm-allocated 6 GHz band
When ACPI disallows 6 GHz, rtw89_regd_setup_6ghz() frees the band and its iftype data with kfree(), even though both are devm-allocated. Devres then frees them again during device teardown.
Only clear the wiphy band pointer and leave the allocations to devres.
---
Compile-tested only. The path needs ACPI that disallows 6 GHz, and rtw89 skips that ACPI check on USB, so my RTL8922AU cannot reach it.
drivers/net/wireless/realtek/rtw89/regd.c | 7 ------- 1 file changed, 7 deletions(-)
drivers/net/wireless/realtek/rtw89/regd.c +0 -7
@@ -590,7 +590,6 @@ static void rtw89_regd_setup_6ghz(struct rtw89_dev *rtwdev, struct wiphy *wiphy)bool chip_support_6ghz =test_bit (NL80211_BAND_6GHZ , rtwdev->supported_bands);bool skip_acpi_dsm = rtwdev->hci.type ==RTW89_HCI_TYPE_USB ;bool regd_allow_6ghz = chip_support_6ghz; -struct ieee80211_supported_band *sband;struct rtw89_acpi_dsm_result res = {};int ret;u8 val;
@@ -635,13 +634,7 @@ static void rtw89_regd_setup_6ghz(struct rtw89_dev *rtwdev, struct wiphy *wiphy)return ; } - sband = wiphy->bands[NL80211_BAND_6GHZ ]; -if (!sband) -return ; - wiphy->bands[NL80211_BAND_6GHZ ] =NULL ; -kfree ((__force void *)sband->iftype_data); -kfree (sband); }#define RTW89_DEF_REGD_STR (regd) \
Signature · 1 line
2.54.0 (Apple Git-157)
Quoted 8 lines · Josef Schlehofer
When ACPI disallows 6 GHz,
rtw89_regd_setup_6ghz()frees the band and its iftype data withkfree(), even though both are devm-allocated. Devres then frees them again during device teardown.Only clear the wiphy band pointer and leave the allocations to devres.
Fixes 145df52a8671 ("wifi: rtw89: Convert rtw89_core_set_supported_band to use devm_*")Signed-off-by Josef Schlehofer <[email protected]>
drivers/net/wireless/realtek/rtw89/regd.c static void rtw89_regd_setup_6ghz(struct rtw89_dev *rtwdev, struct wiphy *wiphy) · line 641
Quoted 8 lines
drivers/net/wireless/realtek/rtw89/regd.c +0
-4@@ -635,13 +634,7 @@ static void rtw89_regd_setup_6ghz(struct rtw89_dev *rtwdev, struct wiphy *wiphy)return ; } - sband = wiphy->bands[NL80211_BAND_6GHZ ]; -if (!sband) -return ; -
nit: I'd like a comment here to be clear that bands allocated by devm.
Quoted 8 lines
drivers/net/wireless/realtek/rtw89/regd.c +0
-3wiphy->bands[NL80211_BAND_6GHZ ] =NULL ; -kfree ((__force void *)sband->iftype_data); -kfree (sband); }#define RTW89_DEF_REGD_STR (regd) \ --2.54.0 (Apple Git-157)
Ping-Ke Shih
maintainerQuoted 9 lines · Josef Schlehofer
When ACPI disallows 6 GHz,
rtw89_regd_setup_6ghz()frees the band and its iftype data withkfree(), even though both are devm-allocated. Devres then frees them again during device teardown.Only clear the wiphy band pointer and leave the allocations to devres.
Fixes 145df52a8671 ("wifi: rtw89: Convert rtw89_core_set_supported_band to use devm_*")Signed-off-by Josef Schlehofer <[email protected]>Acked-by Ping-Ke Shih <[email protected]>
1 patch(es) applied to rtw-next branch of rtw.git, thanks.
b54406f99ed2 wifi: rtw89: regd: avoid freeing devm-allocated 6 GHz band