From bc194f87eeb5638814079ee13b0d91d7fa76c961 Mon Sep 17 00:00:00 2001 From: Michael Buesch Date: Sun, 28 Oct 2007 17:27:10 +0100 Subject: [PATCH] --- yaml --- r: 73449 b: refs/heads/master c: 80fda03fc8b5cd09c3e0e90725ef9bcb2a5c7b30 h: refs/heads/master i: 73447: 1769117fdc7f9b7230b062aacd71afd774d39169 v: v3 --- [refs] | 2 +- trunk/drivers/net/wireless/b43/rfkill.c | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/[refs] b/[refs] index 57101857bfea..16f81e489e62 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: ce2d90591fe69ba19076c5d187dfc88ba3318623 +refs/heads/master: 80fda03fc8b5cd09c3e0e90725ef9bcb2a5c7b30 diff --git a/trunk/drivers/net/wireless/b43/rfkill.c b/trunk/drivers/net/wireless/b43/rfkill.c index 800e0a61a7f5..456930ffef2d 100644 --- a/trunk/drivers/net/wireless/b43/rfkill.c +++ b/trunk/drivers/net/wireless/b43/rfkill.c @@ -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; @@ -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);