net: wireless: bcmdhd: Fix improper band handling
Dmitry Shmidt [Tue, 10 Apr 2012 22:44:41 +0000 (15:44 -0700)]
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>

drivers/net/wireless/bcmdhd/wl_cfg80211.c

index 8009e03..19d675a 100644 (file)
@@ -4509,6 +4509,11 @@ static s32 wl_inform_single_bss(struct wl_priv *wl, struct wl_bss_info *bi)
                band = wiphy->bands[IEEE80211_BAND_2GHZ];
        else
                band = wiphy->bands[IEEE80211_BAND_5GHZ];
+       if (!band) {
+               WL_ERR(("No valid band"));
+               kfree(notif_bss_info);
+               return -EINVAL;
+       }
        notif_bss_info->rssi = dtoh16(bi->RSSI);
        memcpy(mgmt->bssid, &bi->BSSID, ETHER_ADDR_LEN);
        mgmt_type = wl->active_scan ?
@@ -4713,7 +4718,10 @@ wl_notify_connect_status_ap(struct wl_priv *wl, struct net_device *ndev,
                band = wiphy->bands[IEEE80211_BAND_2GHZ];
        else
                band = wiphy->bands[IEEE80211_BAND_5GHZ];
-
+       if (!band) {
+               WL_ERR(("No valid band"));
+               return -EINVAL;
+       }
 #if LINUX_VERSION_CODE == KERNEL_VERSION(2, 6, 38) && !defined(WL_COMPAT_WIRELESS)
        freq = ieee80211_channel_to_frequency(channel);
 #else
@@ -5296,7 +5304,10 @@ wl_notify_rx_mgmt_frame(struct wl_priv *wl, struct net_device *ndev,
                band = wiphy->bands[IEEE80211_BAND_2GHZ];
        else
                band = wiphy->bands[IEEE80211_BAND_5GHZ];
-
+       if (!band) {
+               WL_ERR(("No valid band"));
+               return -EINVAL;
+       }
 #if LINUX_VERSION_CODE == KERNEL_VERSION(2, 6, 38) && !defined(WL_COMPAT_WIRELESS)
        freq = ieee80211_channel_to_frequency(channel);
 #else
@@ -6675,8 +6686,8 @@ s32 wl_update_wiphybands(struct wl_priv *wl)
        }
        wiphy = wl_to_wiphy(wl);
        nband = bandlist[0];
+       wiphy->bands[IEEE80211_BAND_2GHZ] = &__wl_band_2ghz;
        wiphy->bands[IEEE80211_BAND_5GHZ] = NULL;
-       wiphy->bands[IEEE80211_BAND_2GHZ] = NULL;
 
        err = wldev_iovar_getint(wl_to_prmry_ndev(wl), "nmode", &nmode);
        if (unlikely(err)) {
@@ -6690,7 +6701,7 @@ s32 wl_update_wiphybands(struct wl_priv *wl)
                }
        }
 
-       for (i = 1; i <= nband && i < sizeof(bandlist); i++) {
+       for (i = 1; i <= nband && i < sizeof(bandlist)/sizeof(u32); i++) {
                index = -1;
                if (bandlist[i] == WLC_BAND_5G) {
                        wiphy->bands[IEEE80211_BAND_5GHZ] =