net: wireless: bcmdhd: Add mutex to wl_update_wiphybands()
authorDmitry Shmidt <dimitrysh@google.com>
Fri, 29 Jun 2012 16:31:18 +0000 (09:31 -0700)
committerDmitry Shmidt <dimitrysh@google.com>
Thu, 12 Jul 2012 17:45:49 +0000 (10:45 -0700)
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
drivers/net/wireless/bcmdhd/wl_cfg80211.c

index 28c92417b519db1596792a8b8e5c71450c3faf02..121f3bb90986f01c80753d1bf045c116c6a27f07 100644 (file)
@@ -7149,11 +7149,15 @@ s32 wl_update_wiphybands(struct wl_priv *wl)
        int nmode = 0;
        int bw_cap = 0;
        int index = 0;
+       bool rollback_lock = false;
 
        WL_DBG(("Entry"));
 
-       if (wl == NULL)
+       if (wl == NULL) {
                wl = wlcfg_drv_priv;
+               mutex_lock(&wl->usr_sync);
+               rollback_lock = true;
+       }
        dev = wl_to_prmry_ndev(wl);
 
        memset(bandlist, 0, sizeof(bandlist));
@@ -7161,7 +7165,7 @@ s32 wl_update_wiphybands(struct wl_priv *wl)
                sizeof(bandlist), false);
        if (unlikely(err)) {
                WL_ERR(("error read bandlist (%d)\n", err));
-               return err;
+               goto end_bands;
        }
        wiphy = wl_to_wiphy(wl);
        nband = bandlist[0];
@@ -7183,7 +7187,7 @@ s32 wl_update_wiphybands(struct wl_priv *wl)
        if (err) {
                WL_ERR(("wl_construct_reginfo() fails err=%d\n", err));
                if (err != BCME_UNSUPPORTED)
-                       return err;
+                       goto end_bands;
                /* Ignore error if "chanspecs" command is not supported */
                err = 0;
        }
@@ -7212,6 +7216,9 @@ s32 wl_update_wiphybands(struct wl_priv *wl)
        }
 
        wiphy_apply_custom_regulatory(wiphy, &brcm_regdom);
+end_bands:
+       if (rollback_lock)
+               mutex_unlock(&wl->usr_sync);
        return err;
 }