Skip to contentSkip to conversation

wifi: rtw89: regd: avoid freeing devm-allocated 6 GHz band

PATCH In review Josef Schlehofer 2 participants 3 messages Nov 29 – Dec 1 Realtek wireless driver (rtw89)

lore
Share & tools
lore
#0 lore raw

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.

Fixes 145df52a8671 ("wifi: rtw89: Convert rtw89_core_set_supported_band to use devm_*")

---
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
index 017e6a2b4b0..e8a383c6680 100644
@@ -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)
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 8 lines · Josef Schlehofer

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.

Fixes 145df52a8671 ("wifi: rtw89: Convert rtw89_core_set_supported_band to use devm_*")

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 -3
        wiphy->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)

maintainer
#2 lore raw
In reply to Josef Schlehofer
Quoted 9 lines · Josef Schlehofer

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.

Fixes 145df52a8671 ("wifi: rtw89: Convert rtw89_core_set_supported_band to use devm_*")

1 patch(es) applied to rtw-next branch of rtw.git, thanks.

b54406f99ed2 wifi: rtw89: regd: avoid freeing devm-allocated 6 GHz band

---
https://github.com/pkshih/rtw.git