staging: brcm80211: clean up rtnl_lock in fullmac
authorFranky Lin <frankyl@broadcom.com>
Tue, 4 Oct 2011 21:18:53 +0000 (23:18 +0200)
committerGreg Kroah-Hartman <gregkh@suse.de>
Wed, 5 Oct 2011 20:39:01 +0000 (13:39 -0700)
rtnl lock is used improperly in fullmac. This patch intends to clean
them up.

Reported-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Arend van Spriel <arend@broadcom.com>
Reviewed-by: Roland Vossen <rvossen@broadcom.com>
Reviewed-by: Sukesh Srikakula <sukeshs@broadcom.com>
Reviewed-by: Pieter-Paul Giesberts <pieterpg@broadcom.com>
Signed-off-by: Arend van Spriel <arend@broadcom.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/staging/brcm80211/brcmfmac/dhd_linux.c
drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c

index 641cd9c7f042cf54d0b7ed9a784d2083e0ef2562..804b2bc64b150291db364579b5cb2d3a43221801 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/mutex.h>
 #include <linux/wait.h>
 #include <net/cfg80211.h>
+#include <net/rtnetlink.h>
 #include <defs.h>
 #include <brcmu_utils.h>
 #include <brcmu_wifi.h>
@@ -1240,7 +1241,9 @@ void brcmf_detach(struct brcmf_pub *drvr)
 
                        ifp = drvr_priv->iflist[0];
                        if (ifp->ndev->netdev_ops == &brcmf_netdev_ops_pri) {
+                               rtnl_lock();
                                brcmf_netdev_stop(ifp->ndev);
+                               rtnl_unlock();
                                unregister_netdev(ifp->ndev);
                        }
 
index f7b3077aec95a8541e81a8a2a3dec85424700ea1..fc643c1eb59a6f2c8be1de1e99c3d945a8cd6b25 100644 (file)
@@ -26,7 +26,6 @@
 #include <linux/ieee80211.h>
 #include <linux/uaccess.h>
 #include <net/cfg80211.h>
-#include <net/rtnetlink.h>
 
 #include <brcmu_utils.h>
 #include <defs.h>
@@ -2223,10 +2222,8 @@ static s32 brcmf_iscan_done(struct brcmf_cfg80211_priv *cfg_priv)
        s32 err = 0;
 
        iscan->state = WL_ISCAN_STATE_IDLE;
-       rtnl_lock();
        brcmf_inform_bss(cfg_priv);
        brcmf_notify_iscan_complete(iscan, false);
-       rtnl_unlock();
 
        return err;
 }
@@ -2248,10 +2245,8 @@ static s32 brcmf_iscan_inprogress(struct brcmf_cfg80211_priv *cfg_priv)
        struct brcmf_cfg80211_iscan_ctrl *iscan = cfg_priv->iscan;
        s32 err = 0;
 
-       rtnl_lock();
        brcmf_inform_bss(cfg_priv);
        brcmf_run_iscan(iscan, NULL, BRCMF_SCAN_ACTION_CONTINUE);
-       rtnl_unlock();
        /* Reschedule the timer */
        mod_timer(&iscan->timer, jiffies + iscan->timer_ms * HZ / 1000);
        iscan->timer_on = 1;
@@ -2265,9 +2260,7 @@ static s32 brcmf_iscan_aborted(struct brcmf_cfg80211_priv *cfg_priv)
        s32 err = 0;
 
        iscan->state = WL_ISCAN_STATE_IDLE;
-       rtnl_lock();
        brcmf_notify_iscan_complete(iscan, true);
-       rtnl_unlock();
 
        return err;
 }
@@ -2286,12 +2279,10 @@ static void brcmf_cfg80211_iscan_handler(struct work_struct *work)
                iscan->timer_on = 0;
        }
 
-       rtnl_lock();
        if (brcmf_get_iscan_results(iscan, &status, &cfg_priv->bss_list)) {
                status = BRCMF_SCAN_RESULTS_ABORTED;
                WL_ERR("Abort iscan\n");
        }
-       rtnl_unlock();
 
        el->handler[status](cfg_priv);
 }
@@ -2408,9 +2399,7 @@ static s32 brcmf_cfg80211_suspend(struct wiphy *wiphy,
                 * generated due to DISASSOC call to the fw to keep
                 * the state fw and WPA_Supplicant state consistent
                 */
-               rtnl_unlock();
                brcmf_delay(500);
-               rtnl_lock();
        }
 
        set_bit(WL_STATUS_SCAN_ABORTING, &cfg_priv->status);
@@ -2978,7 +2967,6 @@ brcmf_notify_mic_status(struct brcmf_cfg80211_priv *cfg_priv,
        u16 flags = be16_to_cpu(e->flags);
        enum nl80211_key_type key_type;
 
-       rtnl_lock();
        if (flags & BRCMF_EVENT_MSG_GROUP)
                key_type = NL80211_KEYTYPE_GROUP;
        else
@@ -2986,7 +2974,6 @@ brcmf_notify_mic_status(struct brcmf_cfg80211_priv *cfg_priv,
 
        cfg80211_michael_mic_failure(ndev, (u8 *)&e->addr, key_type, -1,
                                     NULL, GFP_KERNEL);
-       rtnl_unlock();
 
        return 0;
 }
@@ -3563,8 +3550,7 @@ static s32 brcmf_dongle_probecap(struct brcmf_cfg80211_priv *cfg_priv)
        return wl_update_wiphybands(cfg_priv);
 }
 
-static s32 brcmf_config_dongle(struct brcmf_cfg80211_priv *cfg_priv,
-                              bool need_lock)
+static s32 brcmf_config_dongle(struct brcmf_cfg80211_priv *cfg_priv)
 {
        struct net_device *ndev;
        struct wireless_dev *wdev;
@@ -3576,8 +3562,6 @@ static s32 brcmf_config_dongle(struct brcmf_cfg80211_priv *cfg_priv,
 
        ndev = cfg_to_ndev(cfg_priv);
        wdev = ndev->ieee80211_ptr;
-       if (need_lock)
-               rtnl_lock();
 
        brcmf_dongle_scantime(ndev, WL_SCAN_CHANNEL_TIME,
                        WL_SCAN_UNASSOC_TIME, WL_SCAN_PASSIVE_TIME);
@@ -3607,8 +3591,6 @@ static s32 brcmf_config_dongle(struct brcmf_cfg80211_priv *cfg_priv,
        /* -EINPROGRESS: Call commit handler */
 
 default_conf_out:
-       if (need_lock)
-               rtnl_unlock();
 
        cfg_priv->dongle_up = true;
 
@@ -3658,7 +3640,7 @@ static s32 __brcmf_cfg80211_up(struct brcmf_cfg80211_priv *cfg_priv)
 
        brcmf_debugfs_add_netdev_params(cfg_priv);
 
-       err = brcmf_config_dongle(cfg_priv, false);
+       err = brcmf_config_dongle(cfg_priv);
        if (err)
                return err;
 
@@ -3683,9 +3665,7 @@ static s32 __brcmf_cfg80211_down(struct brcmf_cfg80211_priv *cfg_priv)
                   generated due to DISASSOC call to the fw to keep
                   the state fw and WPA_Supplicant state consistent
                 */
-               rtnl_unlock();
                brcmf_delay(500);
-               rtnl_lock();
        }
 
        set_bit(WL_STATUS_SCAN_ABORTING, &cfg_priv->status);