]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
nl80211: Filter out unsupported bands
authorJouni Malinen <jouni@codeaurora.org>
Mon, 26 Oct 2020 20:34:07 +0000 (22:34 +0200)
committerJouni Malinen <j@w1.fi>
Mon, 26 Oct 2020 20:34:07 +0000 (22:34 +0200)
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 <jouni@codeaurora.org>
src/drivers/driver_nl80211_capa.c

index 625fe5d0bc5e11f907d9d6782e2eb46a939dc2b7..227f665c7a3c50f9a0fea4dfa93d984b5cf01698 100644 (file)
@@ -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. */