* [PATCH] wifi: rtw89: Don't return default channel from disabled bands
@ 2026-08-12 20:36 Nícolas F. R. A. Prado
2026-08-13 0:52 ` Ping-Ke Shih
0 siblings, 1 reply; 2+ messages in thread
From: Nícolas F. R. A. Prado @ 2026-08-12 20:36 UTC (permalink / raw)
To: Ping-Ke Shih, David Lee
Cc: kernel, linux-wireless, linux-kernel, Nícolas F. R. A. Prado
rtw89_get_default_chandef() assumes the lowest frequency channel in the
2GHz band is available on all hardware, and always returns that as the
default channel. This is no longer the case after commit 355626a2c232
("wifi: rtw89: 8852cu: add quirk to disable 2.4 GHz band"), and the
current logic results in kernel WARNs and null pointer dereferences on
boards with that quirk set.
Update rtw89_get_default_chandef() to consider the available bands when
picking the default channel.
Fixes: 355626a2c232 ("wifi: rtw89: 8852cu: add quirk to disable 2.4 GHz band")
Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
---
drivers/net/wireless/realtek/rtw89/chan.c | 2 +-
drivers/net/wireless/realtek/rtw89/core.c | 21 ++++++++++++++++++---
drivers/net/wireless/realtek/rtw89/core.h | 3 ++-
3 files changed, 21 insertions(+), 5 deletions(-)
diff --git a/drivers/net/wireless/realtek/rtw89/chan.c b/drivers/net/wireless/realtek/rtw89/chan.c
index 6f11335b4968..6512fc9eef29 100644
--- a/drivers/net/wireless/realtek/rtw89/chan.c
+++ b/drivers/net/wireless/realtek/rtw89/chan.c
@@ -297,7 +297,7 @@ static void rtw89_config_default_chandef(struct rtw89_dev *rtwdev)
{
struct cfg80211_chan_def chandef = {0};
- rtw89_get_default_chandef(&chandef);
+ rtw89_get_default_chandef(rtwdev, &chandef);
__rtw89_config_entity_chandef(rtwdev, RTW89_CHANCTX_0, &chandef);
}
diff --git a/drivers/net/wireless/realtek/rtw89/core.c b/drivers/net/wireless/realtek/rtw89/core.c
index 397ebbfcac09..5ae9523667c6 100644
--- a/drivers/net/wireless/realtek/rtw89/core.c
+++ b/drivers/net/wireless/realtek/rtw89/core.c
@@ -393,10 +393,25 @@ static void rtw89_traffic_stats_accu(struct rtw89_dev *rtwdev,
}
}
-void rtw89_get_default_chandef(struct cfg80211_chan_def *chandef)
+void rtw89_get_default_chandef(struct rtw89_dev *rtwdev,
+ struct cfg80211_chan_def *chandef)
{
- cfg80211_chandef_create(chandef, &rtw89_channels_2ghz[0],
- NL80211_CHAN_NO_HT);
+ u8 support_bands = rtwdev->chip->support_bands;
+ struct ieee80211_channel *default_channel;
+
+ if (support_bands & BIT(NL80211_BAND_2GHZ) &&
+ !test_bit(RTW89_QUIRK_DISABLE_2GHZ, rtwdev->quirks)) {
+ default_channel = &rtw89_channels_2ghz[0];
+ } else if (support_bands & BIT(NL80211_BAND_5GHZ)) {
+ default_channel = &rtw89_channels_5ghz[0];
+ } else if (support_bands & BIT(NL80211_BAND_6GHZ)) {
+ default_channel = &rtw89_channels_6ghz[0];
+ } else {
+ rtw89_err(rtwdev, "Failed to get default channel, no band supported\n");
+ return;
+ }
+
+ cfg80211_chandef_create(chandef, default_channel, NL80211_CHAN_NO_HT);
}
void rtw89_get_channel_params(const struct cfg80211_chan_def *chandef,
diff --git a/drivers/net/wireless/realtek/rtw89/core.h b/drivers/net/wireless/realtek/rtw89/core.h
index 2b21d969ece7..2a101fa4bbca 100644
--- a/drivers/net/wireless/realtek/rtw89/core.h
+++ b/drivers/net/wireless/realtek/rtw89/core.h
@@ -9324,7 +9324,8 @@ void rtw89_chip_rfk_channel(struct rtw89_dev *rtwdev,
struct rtw89_vif_link *rtwvif_link);
const struct rtw89_6ghz_span *
rtw89_get_6ghz_span(struct rtw89_dev *rtwdev, u32 center_freq);
-void rtw89_get_default_chandef(struct cfg80211_chan_def *chandef);
+void rtw89_get_default_chandef(struct rtw89_dev *rtwdev,
+ struct cfg80211_chan_def *chandef);
void rtw89_get_channel_params(const struct cfg80211_chan_def *chandef,
struct rtw89_chan *chan);
int rtw89_set_channel(struct rtw89_dev *rtwdev);
---
base-commit: ca800a9302764c445de0da0e84d2252400a770ee
change-id: 20260812-rtw89-2ghz-quirk-fix-ccf37270c982
Best regards,
--
Nícolas F. R. A. Prado <nfraprado@collabora.com>
^ permalink raw reply related [flat|nested] 2+ messages in thread* RE: [PATCH] wifi: rtw89: Don't return default channel from disabled bands
2026-08-12 20:36 [PATCH] wifi: rtw89: Don't return default channel from disabled bands Nícolas F. R. A. Prado
@ 2026-08-13 0:52 ` Ping-Ke Shih
0 siblings, 0 replies; 2+ messages in thread
From: Ping-Ke Shih @ 2026-08-13 0:52 UTC (permalink / raw)
To: Nícolas F. R. A. Prado, David Lee
Cc: kernel@collabora.com, linux-wireless@vger.kernel.org,
linux-kernel@vger.kernel.org, Zong-Zhe Yang
Nícolas F. R. A. Prado <nfraprado@collabora.com> wrote:
> rtw89_get_default_chandef() assumes the lowest frequency channel in the
> 2GHz band is available on all hardware, and always returns that as the
> default channel. This is no longer the case after commit 355626a2c232
> ("wifi: rtw89: 8852cu: add quirk to disable 2.4 GHz band"), and the
> current logic results in kernel WARNs and null pointer dereferences on
> boards with that quirk set.
Could you share the kernel WARN?
>
> Update rtw89_get_default_chandef() to consider the available bands when
> picking the default channel.
>
> Fixes: 355626a2c232 ("wifi: rtw89: 8852cu: add quirk to disable 2.4 GHz band")
> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
> ---
> drivers/net/wireless/realtek/rtw89/chan.c | 2 +-
> drivers/net/wireless/realtek/rtw89/core.c | 21 ++++++++++++++++++---
> drivers/net/wireless/realtek/rtw89/core.h | 3 ++-
> 3 files changed, 21 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/net/wireless/realtek/rtw89/chan.c b/drivers/net/wireless/realtek/rtw89/chan.c
> index 6f11335b4968..6512fc9eef29 100644
> --- a/drivers/net/wireless/realtek/rtw89/chan.c
> +++ b/drivers/net/wireless/realtek/rtw89/chan.c
> @@ -297,7 +297,7 @@ static void rtw89_config_default_chandef(struct rtw89_dev *rtwdev)
> {
> struct cfg80211_chan_def chandef = {0};
>
> - rtw89_get_default_chandef(&chandef);
> + rtw89_get_default_chandef(rtwdev, &chandef);
> __rtw89_config_entity_chandef(rtwdev, RTW89_CHANCTX_0, &chandef);
> }
>
> diff --git a/drivers/net/wireless/realtek/rtw89/core.c b/drivers/net/wireless/realtek/rtw89/core.c
> index 397ebbfcac09..5ae9523667c6 100644
> --- a/drivers/net/wireless/realtek/rtw89/core.c
> +++ b/drivers/net/wireless/realtek/rtw89/core.c
> @@ -393,10 +393,25 @@ static void rtw89_traffic_stats_accu(struct rtw89_dev *rtwdev,
> }
> }
>
> -void rtw89_get_default_chandef(struct cfg80211_chan_def *chandef)
> +void rtw89_get_default_chandef(struct rtw89_dev *rtwdev,
> + struct cfg80211_chan_def *chandef)
> {
> - cfg80211_chandef_create(chandef, &rtw89_channels_2ghz[0],
> - NL80211_CHAN_NO_HT);
> + u8 support_bands = rtwdev->chip->support_bands;
> + struct ieee80211_channel *default_channel;
> +
> + if (support_bands & BIT(NL80211_BAND_2GHZ) &&
> + !test_bit(RTW89_QUIRK_DISABLE_2GHZ, rtwdev->quirks)) {
I'd prefer the style implemented in rtw89_core_set_supported_band() before
this if-branch.
if (test_bit(RTW89_QUIRK_DISABLE_2GHZ, rtwdev->quirks))
support_bands &= ~BIT(NL80211_BAND_2GHZ);
> + default_channel = &rtw89_channels_2ghz[0];
> + } else if (support_bands & BIT(NL80211_BAND_5GHZ)) {
> + default_channel = &rtw89_channels_5ghz[0];
> + } else if (support_bands & BIT(NL80211_BAND_6GHZ)) {
> + default_channel = &rtw89_channels_6ghz[0];
> + } else {
> + rtw89_err(rtwdev, "Failed to get default channel, no band supported\n");
> + return;
If it somehow falls into this case, won't it warn or null-dereference?
> + }
> +
> + cfg80211_chandef_create(chandef, default_channel, NL80211_CHAN_NO_HT);
> }
>
> void rtw89_get_channel_params(const struct cfg80211_chan_def *chandef,
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-08-13 0:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-12 20:36 [PATCH] wifi: rtw89: Don't return default channel from disabled bands Nícolas F. R. A. Prado
2026-08-13 0:52 ` Ping-Ke Shih
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox