Skip to content

Commit

Permalink
[PATCH] bcm43xx: fix race condition in periodic work handler
Browse files Browse the repository at this point in the history
There is a potential race condition in the periodic_work_handler routine
of bcm43xx-softmac. In addition to fixing this condition, the size of code is
reduced by moving the mutex lock outside the if.

Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
  • Loading branch information
Michael Buesch authored and John W. Linville committed Oct 17, 2006
1 parent 51018b0 commit 3693ec6
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions drivers/net/wireless/bcm43xx/bcm43xx_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3164,12 +3164,12 @@ static void bcm43xx_periodic_work_handler(void *d)
u32 savedirqs = 0;
int badness;

mutex_lock(&bcm->mutex);
badness = estimate_periodic_work_badness(bcm->periodic_state);
if (badness > BADNESS_LIMIT) {
/* Periodic work will take a long time, so we want it to
* be preemtible.
*/
mutex_lock(&bcm->mutex);
netif_tx_disable(bcm->net_dev);
spin_lock_irqsave(&bcm->irq_lock, flags);
bcm43xx_mac_suspend(bcm);
Expand All @@ -3182,7 +3182,6 @@ static void bcm43xx_periodic_work_handler(void *d)
/* Periodic work should take short time, so we want low
* locking overhead.
*/
mutex_lock(&bcm->mutex);
spin_lock_irqsave(&bcm->irq_lock, flags);
}

Expand Down

0 comments on commit 3693ec6

Please sign in to comment.