ath9k: fix panic while cleaning up virtaul wifis
authorRajkumar Manoharan <rmanoharan@atheros.com>
Thu, 8 Jul 2010 06:42:29 +0000 (12:12 +0530)
committerJohn W. Linville <linville@tuxdriver.com>
Wed, 14 Jul 2010 17:52:45 +0000 (13:52 -0400)
num_sec_wiphy means max secondary wifis that the driver can accomudate.
So cancelling wiphy work should be based on the presence of
secondary wifis.

Signed-off-by: Rajkumar Manoharan <rmanoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/ath/ath9k/init.c
drivers/net/wireless/ath/ath9k/main.c

index fe730cb16ec218c3dc058692720d8143ac9ca1a8..243c1775f343f0b3400b0675708ee292bcb54e74 100644 (file)
@@ -787,12 +787,12 @@ void ath9k_deinit_device(struct ath_softc *sc)
                ieee80211_unregister_hw(aphy->hw);
                ieee80211_free_hw(aphy->hw);
        }
-       kfree(sc->sec_wiphy);
 
        ieee80211_unregister_hw(hw);
        ath_rx_cleanup(sc);
        ath_tx_cleanup(sc);
        ath9k_deinit_softc(sc);
+       kfree(sc->sec_wiphy);
 }
 
 void ath_descdma_cleanup(struct ath_softc *sc,
index 56d4a93cd8e518d500fd40de4daef026aee070e4..d45cf0b5db05ad3aefb45caa2faee5458c648e57 100644 (file)
@@ -1269,6 +1269,7 @@ static void ath9k_stop(struct ieee80211_hw *hw)
        struct ath_softc *sc = aphy->sc;
        struct ath_hw *ah = sc->sc_ah;
        struct ath_common *common = ath9k_hw_common(ah);
+       int i;
 
        mutex_lock(&sc->mutex);
 
@@ -1281,7 +1282,12 @@ static void ath9k_stop(struct ieee80211_hw *hw)
        cancel_work_sync(&sc->paprd_work);
        cancel_work_sync(&sc->hw_check_work);
 
-       if (!sc->num_sec_wiphy) {
+       for (i = 0; i < sc->num_sec_wiphy; i++) {
+               if (sc->sec_wiphy[i])
+                       break;
+       }
+
+       if (i == sc->num_sec_wiphy) {
                cancel_delayed_work_sync(&sc->wiphy_work);
                cancel_work_sync(&sc->chan_work);
        }