From 00f22ee771724c839d531778ca9505d13985824e Mon Sep 17 00:00:00 2001 From: Adrian Chadd Date: Fri, 12 May 2017 06:05:34 +0000 Subject: [PATCH] [iwm] Handle AUTH->SCAN/INIT and ASSOC->SCAN/INIT better * Tear down the relevant firmware state (i.e. the station, the vif binding) in these transition cases. * Before this case would leave the firmware state lying around, resulting in errors and firmware panics in the subsequent association attempts. Obtained from: dragonflybsd.git 94b501399fde6368ae388a669c95b099a6e66e93 --- sys/dev/iwm/if_iwm.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/sys/dev/iwm/if_iwm.c b/sys/dev/iwm/if_iwm.c index 3565b3e6dc47..081650108c68 100644 --- a/sys/dev/iwm/if_iwm.c +++ b/sys/dev/iwm/if_iwm.c @@ -4364,6 +4364,39 @@ iwm_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg) switch (nstate) { case IEEE80211_S_INIT: + case IEEE80211_S_SCAN: + if (vap->iv_state == IEEE80211_S_AUTH || + vap->iv_state == IEEE80211_S_ASSOC) { + int myerr; + IWM_UNLOCK(sc); + IEEE80211_LOCK(ic); + myerr = ivp->iv_newstate(vap, nstate, arg); + IEEE80211_UNLOCK(ic); + IWM_LOCK(sc); + in = IWM_NODE(vap->iv_bss); + error = iwm_mvm_rm_sta(sc, vap, in); + if (error) { + device_printf(sc->sc_dev, + "%s: Failed to remove station: %d\n", + __func__, error); + } + error = iwm_mvm_mac_ctxt_changed(sc, vap); + if (error) { + device_printf(sc->sc_dev, + "%s: Failed to change mac context: %d\n", + __func__, error); + } + error = iwm_mvm_binding_remove_vif(sc, ivp); + if (error) { + device_printf(sc->sc_dev, + "%s: Failed to remove channel ctx: %d\n", + __func__, error); + } + ivp->phy_ctxt = NULL; + IWM_UNLOCK(sc); + IEEE80211_LOCK(ic); + return myerr; + } break; case IEEE80211_S_AUTH: