diff options
author | Johannes Berg <johannes.berg@intel.com> | 2010-01-20 14:21:06 -0500 |
---|---|---|
committer | Reinette Chatre <reinette.chatre@intel.com> | 2010-01-29 14:13:34 -0500 |
commit | 47e28f41dce90ea4317d35cf23f232c1a6b07adf (patch) | |
tree | 8ddc9b6044c994c5c68f1fc348e9b301fd8ccd6e | |
parent | a7fce6ee8dd693fb2a9d19ddf9ee1fe380893fa1 (diff) |
iwlwifi: fix locking in iwl_mac_add_interface
The corresponding iwl_mac_remove_interface only
acquires the mutex, leading me to believe that
the spinlock is not necessary. However, this
doesn't actually acquire the mutex around the
vif pointer check and assignment, fix that.
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-core.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c index 1cfabd6be0b8..02bf17ecaf54 100644 --- a/drivers/net/wireless/iwlwifi/iwl-core.c +++ b/drivers/net/wireless/iwlwifi/iwl-core.c | |||
@@ -2631,23 +2631,21 @@ int iwl_mac_add_interface(struct ieee80211_hw *hw, | |||
2631 | struct ieee80211_vif *vif) | 2631 | struct ieee80211_vif *vif) |
2632 | { | 2632 | { |
2633 | struct iwl_priv *priv = hw->priv; | 2633 | struct iwl_priv *priv = hw->priv; |
2634 | unsigned long flags; | 2634 | int err = 0; |
2635 | 2635 | ||
2636 | IWL_DEBUG_MAC80211(priv, "enter: type %d\n", vif->type); | 2636 | IWL_DEBUG_MAC80211(priv, "enter: type %d\n", vif->type); |
2637 | 2637 | ||
2638 | mutex_lock(&priv->mutex); | ||
2639 | |||
2638 | if (priv->vif) { | 2640 | if (priv->vif) { |
2639 | IWL_DEBUG_MAC80211(priv, "leave - vif != NULL\n"); | 2641 | IWL_DEBUG_MAC80211(priv, "leave - vif != NULL\n"); |
2640 | return -EOPNOTSUPP; | 2642 | err = -EOPNOTSUPP; |
2643 | goto out; | ||
2641 | } | 2644 | } |
2642 | 2645 | ||
2643 | spin_lock_irqsave(&priv->lock, flags); | ||
2644 | priv->vif = vif; | 2646 | priv->vif = vif; |
2645 | priv->iw_mode = vif->type; | 2647 | priv->iw_mode = vif->type; |
2646 | 2648 | ||
2647 | spin_unlock_irqrestore(&priv->lock, flags); | ||
2648 | |||
2649 | mutex_lock(&priv->mutex); | ||
2650 | |||
2651 | if (vif->addr) { | 2649 | if (vif->addr) { |
2652 | IWL_DEBUG_MAC80211(priv, "Set %pM\n", vif->addr); | 2650 | IWL_DEBUG_MAC80211(priv, "Set %pM\n", vif->addr); |
2653 | memcpy(priv->mac_addr, vif->addr, ETH_ALEN); | 2651 | memcpy(priv->mac_addr, vif->addr, ETH_ALEN); |
@@ -2657,10 +2655,11 @@ int iwl_mac_add_interface(struct ieee80211_hw *hw, | |||
2657 | /* we are not ready, will run again when ready */ | 2655 | /* we are not ready, will run again when ready */ |
2658 | set_bit(STATUS_MODE_PENDING, &priv->status); | 2656 | set_bit(STATUS_MODE_PENDING, &priv->status); |
2659 | 2657 | ||
2658 | out: | ||
2660 | mutex_unlock(&priv->mutex); | 2659 | mutex_unlock(&priv->mutex); |
2661 | 2660 | ||
2662 | IWL_DEBUG_MAC80211(priv, "leave\n"); | 2661 | IWL_DEBUG_MAC80211(priv, "leave\n"); |
2663 | return 0; | 2662 | return err; |
2664 | } | 2663 | } |
2665 | EXPORT_SYMBOL(iwl_mac_add_interface); | 2664 | EXPORT_SYMBOL(iwl_mac_add_interface); |
2666 | 2665 | ||