Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3693ec67 authored by Michael Buesch's avatar Michael Buesch Committed by John W. Linville
Browse files

[PATCH] bcm43xx: fix race condition in periodic work handler



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: default avatarLarry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 51018b0a
Loading
Loading
Loading
Loading
+1 −2
Original line number Original line Diff line number Diff line
@@ -3164,12 +3164,12 @@ static void bcm43xx_periodic_work_handler(void *d)
	u32 savedirqs = 0;
	u32 savedirqs = 0;
	int badness;
	int badness;


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