Skip to content

Commit

Permalink
b43: Fix rfkill callback deadlock
Browse files Browse the repository at this point in the history
wl->mutex might already be locked on initialization.

Signed-off-by: Michael Buesch <mb@bu3sch.de>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
  • Loading branch information
Michael Buesch authored and Jeff Garzik committed Nov 10, 2007
1 parent ce2d905 commit 80fda03
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions drivers/net/wireless/b43/rfkill.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,22 @@ static void b43_rfkill_poll(struct input_polled_dev *poll_dev)
mutex_unlock(&wl->mutex);
}

/* Called when the RFKILL toggled in software.
* This is called without locking. */
/* Called when the RFKILL toggled in software. */
static int b43_rfkill_soft_toggle(void *data, enum rfkill_state state)
{
struct b43_wldev *dev = data;
struct b43_wl *wl = dev->wl;
int err = 0;

mutex_lock(&wl->mutex);
/* When RFKILL is registered, it will call back into this callback.
* wl->mutex will already be locked when this happens.
* So first trylock. On contention check if we are in initialization.
* Silently return if that happens to avoid a deadlock. */
if (mutex_trylock(&wl->mutex) == 0) {
if (b43_status(dev) < B43_STAT_INITIALIZED)
return 0;
mutex_lock(&wl->mutex);
}
if (b43_status(dev) < B43_STAT_INITIALIZED)
goto out_unlock;

Expand All @@ -89,7 +96,6 @@ static int b43_rfkill_soft_toggle(void *data, enum rfkill_state state)
b43_radio_turn_off(dev, 0);
break;
}

out_unlock:
mutex_unlock(&wl->mutex);

Expand Down

0 comments on commit 80fda03

Please sign in to comment.