]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
iwlwifi: fix bugs in change_interface
authorJohannes Berg <johannes.berg@intel.com>
Tue, 29 Mar 2011 13:29:37 +0000 (06:29 -0700)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 3 Jun 2011 00:31:45 +0000 (09:31 +0900)
commit a2b76b3b31568da9d281a393845f17689594ccdf upstream.

If change_interface gets invoked during a firmware
restart, it may crash; prevent that from happening
by checking if ctx->vif is assigned.

Additionally, in my initial commit I forgot to set
the vif->p2p variable correctly, so fix that too.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/net/wireless/iwlwifi/iwl-core.c

index bafbe57c960256787c8bd83081c6acc69732e13d..1755729e4a310fb254ad720ba0260aa6d2365da3 100644 (file)
@@ -1783,6 +1783,15 @@ int iwl_mac_change_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
 
        mutex_lock(&priv->mutex);
 
+       if (!ctx->vif || !iwl_is_ready_rf(priv)) {
+               /*
+                * Huh? But wait ... this can maybe happen when
+                * we're in the middle of a firmware restart!
+                */
+               err = -EBUSY;
+               goto out;
+       }
+
        interface_modes = ctx->interface_modes | ctx->exclusive_interface_modes;
 
        if (!(interface_modes & BIT(newtype))) {
@@ -1810,6 +1819,7 @@ int iwl_mac_change_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
        /* success */
        iwl_teardown_interface(priv, vif, true);
        vif->type = newtype;
+       vif->p2p = newp2p;
        err = iwl_setup_interface(priv, ctx);
        WARN_ON(err);
        /*