net: wireless: bcmdhd: Fix improper band handling
authorDmitry Shmidt <dimitrysh@google.com>
Tue, 10 Apr 2012 22:44:41 +0000 (15:44 -0700)
committerDmitry Shmidt <dimitrysh@google.com>
Tue, 10 Apr 2012 23:38:00 +0000 (16:38 -0700)
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
drivers/net/wireless/bcmdhd/wl_cfg80211.c

index 9358cf1a8314b5b04560fff4c4a5418e97070a94..9bc0f9c8ecd6d542742331d4d813f7caf2819eee 100644 (file)
@@ -4506,6 +4506,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 ?
@@ -4710,7 +4715,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
@@ -5293,7 +5301,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
@@ -6672,8 +6683,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)) {
@@ -6687,7 +6698,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] =