Linux wireless drivers development
 help / color / mirror / Atom feed
From: Josef Schlehofer <pepe.schlehofer@gmail.com>
To: Jeff Johnson <jjohnson@kernel.org>
Cc: linux-wireless@vger.kernel.org
Subject: [PATCH ath-next 7/9] wifi: ath6kl: handle unsupported connection frequencies
Date: Mon, 30 Nov 2026 10:50:40 +0100	[thread overview]
Message-ID: <20261130095042.41330-8-pepe.schlehofer@gmail.com> (raw)
In-Reply-To: <20261130095042.41330-1-pepe.schlehofer@gmail.com>

The firmware picks the network on its own and reports the frequency in
the connect event. ath6kl looks up the channel for it and passes the
result to cfg80211. The channel tables of ath6kl do not cover every
frequency. Channel 144 is missing, for example, and channels 184 to
196 sit at 5920 to 5980 MHz instead of 4920 to 4980 MHz. For a
connection on such a frequency the lookup returns NULL.
cfg80211_inform_bss() then dereferences it when ath6kl adds the BSS,
and the channel switch notification for an AP passes it to
cfg80211_chandef_create(), which warns and leaves the chandef
uninitialised.

Reject such a connection. Send a disconnect and run the normal
disconnect handling, so cfg80211 sees the connection fail or end and
the link is not marked up. Skip the channel switch notification for
such a frequency.

The next patch can drop a whole band for a board, which makes this
case more likely.

Signed-off-by: Josef Schlehofer <pepe.schlehofer@gmail.com>
---
On the test router the 2.4 GHz band was dropped through the device
tree and wpa_supplicant left the choice of network to the firmware
(ap_scan=2). The firmware connected on 2437 MHz, the connection was
rejected, the AP saw the station leave and cfg80211 reported a failed
connect. The channel switch check could not be triggered. An AP starts
on the channel the host gives it, so that check only guards against
firmware that reports a different one.

 drivers/net/wireless/ath/ath6kl/cfg80211.c | 11 +++++++++--
 drivers/net/wireless/ath/ath6kl/main.c     | 12 ++++++++++++
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c
index 6b03627e2..7f1ffe4b7 100644
--- a/drivers/net/wireless/ath/ath6kl/cfg80211.c
+++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c
@@ -1110,14 +1110,21 @@ void ath6kl_cfg80211_scan_complete_event(struct ath6kl_vif *vif, bool aborted)
 void ath6kl_cfg80211_ch_switch_notify(struct ath6kl_vif *vif, int freq,
 				      enum wmi_phy_mode mode)
 {
+	struct ieee80211_channel *chan;
 	struct cfg80211_chan_def chandef;
 
 	ath6kl_dbg(ATH6KL_DBG_WLAN_CFG,
 		   "channel switch notify nw_type %d freq %d mode %d\n",
 		   vif->nw_type, freq, mode);
 
-	cfg80211_chandef_create(&chandef,
-				ieee80211_get_channel(vif->ar->wiphy, freq),
+	chan = ieee80211_get_channel(vif->ar->wiphy, freq);
+	if (!chan) {
+		ath6kl_err("channel switch to unsupported frequency %d MHz\n",
+			   freq);
+		return;
+	}
+
+	cfg80211_chandef_create(&chandef, chan,
 				(mode == WMI_11G_HT20 &&
 				 vif->ar->band_2ghz.ht_cap.ht_supported) ?
 					NL80211_CHAN_HT20 : NL80211_CHAN_NO_HT);
diff --git a/drivers/net/wireless/ath/ath6kl/main.c b/drivers/net/wireless/ath/ath6kl/main.c
index 9dd39d79f..a062598ce 100644
--- a/drivers/net/wireless/ath/ath6kl/main.c
+++ b/drivers/net/wireless/ath/ath6kl/main.c
@@ -633,6 +633,18 @@ void ath6kl_connect_event(struct ath6kl_vif *vif, u16 channel, u8 *bssid,
 {
 	struct ath6kl *ar = vif->ar;
 
+	/*
+	 * cfg80211 needs a channel for the BSS. Reject a connection on a
+	 * frequency that has no channel on this device.
+	 */
+	if (!ieee80211_get_channel(ar->wiphy, channel)) {
+		ath6kl_err("connected on unsupported frequency %u MHz\n", channel);
+		ath6kl_wmi_disconnect_cmd(ar->wmi, vif->fw_vif_idx);
+		ath6kl_disconnect_event(vif, DISCONNECT_CMD, bssid, 0, NULL,
+					WLAN_REASON_UNSPECIFIED);
+		return;
+	}
+
 	ath6kl_cfg80211_connect_event(vif, channel, bssid,
 				      listen_int, beacon_int,
 				      net_type, beacon_ie_len,
-- 
2.54.0 (Apple Git-157)


  parent reply	other threads:[~2026-11-30  9:50 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30  9:50 [PATCH ath-next 0/9] wifi: ath6kl: add AR6006 hw1.1 (QCA6006) support Josef Schlehofer
2026-11-30  9:50 ` [PATCH ath-next 1/9] wifi: ath6kl: add AR6006 hw1.1 support Josef Schlehofer
2026-11-30  9:50 ` [PATCH ath-next 2/9] wifi: ath6kl: handle the AR6006 WMI layout Josef Schlehofer
2026-11-30  9:50 ` [PATCH ath-next 3/9] wifi: ath6kl: ignore AR6006 regulatory domain events Josef Schlehofer
2026-11-30  9:50 ` [PATCH ath-next 4/9] wifi: ath6kl: use per-device band and channel copies Josef Schlehofer
2026-11-30  9:50 ` [PATCH ath-next 5/9] dt-bindings: net: wireless: add QCA6006 binding Josef Schlehofer
2026-11-30  9:50 ` [PATCH ath-next 6/9] wifi: ath6kl: take the AR6006 MAC address from DT Josef Schlehofer
2026-11-30  9:50 ` Josef Schlehofer [this message]
2026-11-30  9:50 ` [PATCH ath-next 8/9] wifi: ath6kl: honour ieee80211-freq-limit " Josef Schlehofer
2026-11-30  9:50 ` [PATCH ath-next 9/9] wifi: ath6kl: add QCA6006 USB ID Josef Schlehofer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261130095042.41330-8-pepe.schlehofer@gmail.com \
    --to=pepe.schlehofer@gmail.com \
    --cc=jjohnson@kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox