From 106d67a93c2d3da2a8e25984ae7b0e17c85783cd Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Mon, 26 Oct 2020 22:34:07 +0200 Subject: [PATCH] nl80211: Filter out unsupported bands If the driver indicates capability for a band that hostapd/wpa_supplicant does not support, the struct hostapd_hw_modes array of bands got an empty entry for that with NUM_HOSTAPD_MODES as the mode. This resulted in various issues, e.g., with fst_hw_mode_to_band() hitting a WPA_ASSERT(0). Fix this by filtering out unsupported bands from the internal data structures. Signed-off-by: Jouni Malinen --- src/drivers/driver_nl80211_capa.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/drivers/driver_nl80211_capa.c b/src/drivers/driver_nl80211_capa.c index 625fe5d0b..227f665c7 100644 --- a/src/drivers/driver_nl80211_capa.c +++ b/src/drivers/driver_nl80211_capa.c @@ -1963,6 +1963,22 @@ wpa_driver_nl80211_postprocess_modes(struct hostapd_hw_modes *modes, modes[m].mode = HOSTAPD_MODE_IEEE80211A; } + /* Remove unsupported bands */ + m = 0; + while (m < *num_modes) { + if (modes[m].mode == NUM_HOSTAPD_MODES) { + wpa_printf(MSG_DEBUG, + "nl80211: Remove unsupported mode"); + os_free(modes[m].channels); + os_free(modes[m].rates); + os_memmove(&modes[m], &modes[m + 1], + sizeof(struct hostapd_hw_modes)); + (*num_modes)--; + continue; + } + m++; + } + /* If only 802.11g mode is included, use it to construct matching * 802.11b mode data. */