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