mwifiex: minor cleanups w/ sta_list_spinlock in cfg80211.c
authorDouglas Anderson <dianders@chromium.org>
Tue, 3 Oct 2017 15:19:44 +0000 (20:49 +0530)
committerKalle Valo <kvalo@codeaurora.org>
Fri, 13 Oct 2017 09:38:03 +0000 (12:38 +0300)
The sta_list_spinlock looks to be used to control locking of the
list. Specifically when someone has the lock they may be allowed
to modify or delete elements of the list.

That implies that we shouldn't access the fields of the elements
returned by mwifiex_get_sta_entry() after we've released the
spinlock. Let's make some small changes so this is true.

It's unlikely that this matters since it looks to be just error
handling, but it's nice to be clean.

Signed-off-by: Douglas Anderson <dianders@chromium.org>
Signed-off-by: Ganapathi Bhat <gbhat@marvell.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/marvell/mwifiex/cfg80211.c
drivers/net/wireless/marvell/mwifiex/sta_event.c

index cc7d777eb26c7b9d8ad1bd0739ccf2e416120fd6..3638b6130216e6a424ced525a89a97f3ecbea86f 100644 (file)
@@ -3794,9 +3794,8 @@ mwifiex_cfg80211_tdls_chan_switch(struct wiphy *wiphy, struct net_device *dev,
 
        spin_lock_irqsave(&priv->sta_list_spinlock, flags);
        sta_ptr = mwifiex_get_sta_entry(priv, addr);
-       spin_unlock_irqrestore(&priv->sta_list_spinlock, flags);
-
        if (!sta_ptr) {
+               spin_unlock_irqrestore(&priv->sta_list_spinlock, flags);
                wiphy_err(wiphy, "%s: Invalid TDLS peer %pM\n",
                          __func__, addr);
                return -ENOENT;
@@ -3804,15 +3803,18 @@ mwifiex_cfg80211_tdls_chan_switch(struct wiphy *wiphy, struct net_device *dev,
 
        if (!(sta_ptr->tdls_cap.extcap.ext_capab[3] &
              WLAN_EXT_CAPA4_TDLS_CHAN_SWITCH)) {
+               spin_unlock_irqrestore(&priv->sta_list_spinlock, flags);
                wiphy_err(wiphy, "%pM do not support tdls cs\n", addr);
                return -ENOENT;
        }
 
        if (sta_ptr->tdls_status == TDLS_CHAN_SWITCHING ||
            sta_ptr->tdls_status == TDLS_IN_OFF_CHAN) {
+               spin_unlock_irqrestore(&priv->sta_list_spinlock, flags);
                wiphy_err(wiphy, "channel switch is running, abort request\n");
                return -EALREADY;
        }
+       spin_unlock_irqrestore(&priv->sta_list_spinlock, flags);
 
        chan = chandef->chan->hw_value;
        second_chan_offset = mwifiex_get_sec_chan_offset(chan);
@@ -3833,18 +3835,20 @@ mwifiex_cfg80211_tdls_cancel_chan_switch(struct wiphy *wiphy,
 
        spin_lock_irqsave(&priv->sta_list_spinlock, flags);
        sta_ptr = mwifiex_get_sta_entry(priv, addr);
-       spin_unlock_irqrestore(&priv->sta_list_spinlock, flags);
-
        if (!sta_ptr) {
+               spin_unlock_irqrestore(&priv->sta_list_spinlock, flags);
                wiphy_err(wiphy, "%s: Invalid TDLS peer %pM\n",
                          __func__, addr);
        } else if (!(sta_ptr->tdls_status == TDLS_CHAN_SWITCHING ||
                     sta_ptr->tdls_status == TDLS_IN_BASE_CHAN ||
                     sta_ptr->tdls_status == TDLS_IN_OFF_CHAN)) {
+               spin_unlock_irqrestore(&priv->sta_list_spinlock, flags);
                wiphy_err(wiphy, "tdls chan switch not initialize by %pM\n",
                          addr);
-       } else
+       } else {
+               spin_unlock_irqrestore(&priv->sta_list_spinlock, flags);
                mwifiex_stop_tdls_cs(priv, addr);
+       }
 }
 
 static int
index 839df8a9634e86c58367c7149d146d8a9bd36657..d8db412b76c6f01b76e835ce69b5ab26b3fdfc93 100644 (file)
@@ -359,13 +359,12 @@ static void mwifiex_process_uap_tx_pause(struct mwifiex_private *priv,
        } else {
                spin_lock_irqsave(&priv->sta_list_spinlock, flags);
                sta_ptr = mwifiex_get_sta_entry(priv, tp->peermac);
-               spin_unlock_irqrestore(&priv->sta_list_spinlock, flags);
-
                if (sta_ptr && sta_ptr->tx_pause != tp->tx_pause) {
                        sta_ptr->tx_pause = tp->tx_pause;
                        mwifiex_update_ralist_tx_pause(priv, tp->peermac,
                                                       tp->tx_pause);
                }
+               spin_unlock_irqrestore(&priv->sta_list_spinlock, flags);
        }
 }
 
@@ -396,14 +395,13 @@ static void mwifiex_process_sta_tx_pause(struct mwifiex_private *priv,
                if (mwifiex_is_tdls_link_setup(status)) {
                        spin_lock_irqsave(&priv->sta_list_spinlock, flags);
                        sta_ptr = mwifiex_get_sta_entry(priv, tp->peermac);
-                       spin_unlock_irqrestore(&priv->sta_list_spinlock, flags);
-
                        if (sta_ptr && sta_ptr->tx_pause != tp->tx_pause) {
                                sta_ptr->tx_pause = tp->tx_pause;
                                mwifiex_update_ralist_tx_pause(priv,
                                                               tp->peermac,
                                                               tp->tx_pause);
                        }
+                       spin_unlock_irqrestore(&priv->sta_list_spinlock, flags);
                }
        }
 }