brcmfmac: Only handle p2p_stop_device if vif is valid
authorHante Meuleman <meuleman@broadcom.com>
Fri, 18 Sep 2015 20:08:13 +0000 (22:08 +0200)
committerKalle Valo <kvalo@codeaurora.org>
Tue, 29 Sep 2015 07:55:58 +0000 (10:55 +0300)
In some situations it is possible that vif has been removed while
cfg80211 invokes the p2p_stop_device handler. This will result in
crash.

Reviewed-by: Arend Van Spriel <arend@broadcom.com>
Reviewed-by: Pieter-Paul Giesberts <pieterpg@broadcom.com>
Signed-off-by: Hante Meuleman <meuleman@broadcom.com>
Signed-off-by: Arend van Spriel <arend@broadcom.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/brcm80211/brcmfmac/p2p.c

index 83027dcc4aae9927d96c3d399abc8b7403174df1..76e477109e6d9f4c9ccb977edc24aeb45217fd25 100644 (file)
@@ -2327,11 +2327,17 @@ void brcmf_p2p_stop_device(struct wiphy *wiphy, struct wireless_dev *wdev)
        struct brcmf_cfg80211_vif *vif;
 
        vif = container_of(wdev, struct brcmf_cfg80211_vif, wdev);
-       mutex_lock(&cfg->usr_sync);
-       (void)brcmf_p2p_deinit_discovery(p2p);
-       brcmf_abort_scanning(cfg);
-       clear_bit(BRCMF_VIF_STATUS_READY, &vif->sme_state);
-       mutex_unlock(&cfg->usr_sync);
+       /* This call can be result of the unregister_wdev call. In that case
+        * we dont want to do anything anymore. Just return. The config vif
+        * will have been cleared at this point.
+        */
+       if (p2p->bss_idx[P2PAPI_BSSCFG_DEVICE].vif == vif) {
+               mutex_lock(&cfg->usr_sync);
+               (void)brcmf_p2p_deinit_discovery(p2p);
+               brcmf_abort_scanning(cfg);
+               clear_bit(BRCMF_VIF_STATUS_READY, &vif->sme_state);
+               mutex_unlock(&cfg->usr_sync);
+       }
 }
 
 /**