Skip to content

Commit

Permalink
ath9k: fix race conditions when stop device
Browse files Browse the repository at this point in the history
We do not kill any scheduled tasklets when stopping device, that may
cause usage of resources after free. Moreover we enable interrupts
in tasklet function, so we could potentially end with interrupts
enabled when driver is not ready to receive them.

I think patch should fix Ben's kernel crash from:
http://marc.info/?l=linux-wireless&m=129438358921501&w=2

Cc: stable@kernel.org
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
  • Loading branch information
Stanislaw Gruszka authored and John W. Linville committed Jan 27, 2011
1 parent c9234a6 commit 203043f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
5 changes: 0 additions & 5 deletions drivers/net/wireless/ath/ath9k/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -598,8 +598,6 @@ static int ath9k_init_softc(u16 devid, struct ath_softc *sc, u16 subsysid,
err_queues:
ath9k_hw_deinit(ah);
err_hw:
tasklet_kill(&sc->intr_tq);
tasklet_kill(&sc->bcon_tasklet);

kfree(ah);
sc->sc_ah = NULL;
Expand Down Expand Up @@ -807,9 +805,6 @@ static void ath9k_deinit_softc(struct ath_softc *sc)

ath9k_hw_deinit(sc->sc_ah);

tasklet_kill(&sc->intr_tq);
tasklet_kill(&sc->bcon_tasklet);

kfree(sc->sc_ah);
sc->sc_ah = NULL;
}
Expand Down
9 changes: 9 additions & 0 deletions drivers/net/wireless/ath/ath9k/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1309,6 +1309,9 @@ static void ath9k_stop(struct ieee80211_hw *hw)

spin_lock_bh(&sc->sc_pcu_lock);

/* prevent tasklets to enable interrupts once we disable them */
ah->imask &= ~ATH9K_INT_GLOBAL;

/* make sure h/w will not generate any interrupt
* before setting the invalid flag. */
ath9k_hw_disable_interrupts(ah);
Expand All @@ -1326,6 +1329,12 @@ static void ath9k_stop(struct ieee80211_hw *hw)

spin_unlock_bh(&sc->sc_pcu_lock);

/* we can now sync irq and kill any running tasklets, since we already
* disabled interrupts and not holding a spin lock */
synchronize_irq(sc->irq);
tasklet_kill(&sc->intr_tq);
tasklet_kill(&sc->bcon_tasklet);

ath9k_ps_restore(sc);

sc->ps_idle = true;
Expand Down

0 comments on commit 203043f

Please sign in to comment.