]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Verify that channel info is available in hostapd_hw_get_channel()
authorJouni Malinen <jouni@codeaurora.org>
Fri, 26 Apr 2019 13:17:59 +0000 (16:17 +0300)
committerJouni Malinen <j@w1.fi>
Fri, 26 Apr 2019 13:17:59 +0000 (16:17 +0300)
Unexpected CHAN_SWITCH command could get this function using a NULL
pointer if the channel switch was requested while the interface was
already disabled.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
src/ap/hw_features.c

index 9d3d990a281fd749ee163453226031c9210db8c8..8ac33bb39fc070d5f5d4f6bc75c1a085c78a85cb 100644 (file)
@@ -936,11 +936,16 @@ int hostapd_hw_get_channel(struct hostapd_data *hapd, int freq)
        int i, channel;
        struct hostapd_hw_modes *mode;
 
-       channel = hw_get_chan(hapd->iface->current_mode, freq);
-       if (channel)
-               return channel;
+       if (hapd->iface->current_mode) {
+               channel = hw_get_chan(hapd->iface->current_mode, freq);
+               if (channel)
+                       return channel;
+       }
+
        /* Check other available modes since the channel list for the current
         * mode did not include the specified frequency. */
+       if (!hapd->iface->hw_features)
+               return 0;
        for (i = 0; i < hapd->iface->num_hw_features; i++) {
                mode = &hapd->iface->hw_features[i];
                channel = hw_get_chan(mode, freq);