This il->vif is dereferenced in different part of iwlegacy code, so do not nullify it. This should fix random crashes observed in companion with microcode errors i.e. crash in il3945_config_ap(). Additionally this should address also WARNING: at drivers/net/wireless/iwlegacy/common.c:4656 il_mac_remove_interface at least one of the possible reasons of that warning. Cc: stable@vger.kernel.org Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/3945-mac.c | 2 -- drivers/net/wireless/iwlegacy/4965-mac.c | 2 -- drivers/net/wireless/iwlegacy/common.c | 15 ++++++++++++--- 3 files changed, 12 insertions(+), 7 deletions(-) --- linux-3.3.noarch.orig/drivers/net/wireless/iwlegacy/3945-mac.c +++ linux-3.3.noarch/drivers/net/wireless/iwlegacy/3945-mac.c @@ -2684,7 +2684,6 @@ il3945_bg_restart(struct work_struct *da if (test_and_clear_bit(S_FW_ERROR, &il->status)) { mutex_lock(&il->mutex); - il->ctx.vif = NULL; il->is_open = 0; mutex_unlock(&il->mutex); il3945_down(il); --- linux-3.3.noarch.orig/drivers/net/wireless/iwlegacy/4965-mac.c +++ linux-3.3.noarch/drivers/net/wireless/iwlegacy/4965-mac.c @@ -5381,7 +5381,6 @@ il4965_bg_restart(struct work_struct *da if (test_and_clear_bit(S_FW_ERROR, &il->status)) { mutex_lock(&il->mutex); - il->ctx.vif = NULL; il->is_open = 0; __il4965_down(il); --- linux-3.3.noarch.orig/drivers/net/wireless/iwlegacy/common.c +++ linux-3.3.noarch/drivers/net/wireless/iwlegacy/common.c @@ -4575,6 +4575,7 @@ il_mac_add_interface(struct ieee80211_hw struct il_priv *il = hw->priv; struct il_vif_priv *vif_priv = (void *)vif->drv_priv; int err; + bool reset; u32 modes; D_MAC80211("enter: type %d, addr %pM\n", vif->type, vif->addr); @@ -4594,6 +4595,16 @@ il_mac_add_interface(struct ieee80211_hw goto out; } + /* + * We do not support multiple virtual interfaces, but on hardware reset + * we have to add the same interface again. + */ + reset = (il->ctx.vif == vif); + if (il->ctx.vif && !reset) { + err = -EOPNOTSUPP; + goto out; + } + modes = il->ctx.interface_modes | il->ctx.exclusive_interface_modes; if (!(modes & BIT(vif->type))) { err = -EOPNOTSUPP; @@ -4605,8 +4616,11 @@ il_mac_add_interface(struct ieee80211_hw err = il_setup_interface(il, &il->ctx); if (err) { - il->ctx.vif = NULL; - il->iw_mode = NL80211_IFTYPE_STATION; + IL_WARN("Fail to set mode %d\n", vif->type); + if (!reset) { + il->ctx.vif = NULL; + il->iw_mode = NL80211_IFTYPE_STATION; + } } out: