diff options
author | Michael Buesch <mb@bu3sch.de> | 2007-10-28 12:27:10 -0400 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2007-11-10 04:25:12 -0500 |
commit | 80fda03fc8b5cd09c3e0e90725ef9bcb2a5c7b30 (patch) | |
tree | 932dcaed07e467b4c0eec22b32d2ef31e09c301a /drivers/net/wireless | |
parent | ce2d90591fe69ba19076c5d187dfc88ba3318623 (diff) |
b43: Fix rfkill callback deadlock
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>
Diffstat (limited to 'drivers/net/wireless')
-rw-r--r-- | drivers/net/wireless/b43/rfkill.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/drivers/net/wireless/b43/rfkill.c b/drivers/net/wireless/b43/rfkill.c index 800e0a61a7f5..456930ffef2d 100644 --- a/drivers/net/wireless/b43/rfkill.c +++ b/drivers/net/wireless/b43/rfkill.c | |||
@@ -61,15 +61,22 @@ static void b43_rfkill_poll(struct input_polled_dev *poll_dev) | |||
61 | mutex_unlock(&wl->mutex); | 61 | mutex_unlock(&wl->mutex); |
62 | } | 62 | } |
63 | 63 | ||
64 | /* Called when the RFKILL toggled in software. | 64 | /* Called when the RFKILL toggled in software. */ |
65 | * This is called without locking. */ | ||
66 | static int b43_rfkill_soft_toggle(void *data, enum rfkill_state state) | 65 | static int b43_rfkill_soft_toggle(void *data, enum rfkill_state state) |
67 | { | 66 | { |
68 | struct b43_wldev *dev = data; | 67 | struct b43_wldev *dev = data; |
69 | struct b43_wl *wl = dev->wl; | 68 | struct b43_wl *wl = dev->wl; |
70 | int err = 0; | 69 | int err = 0; |
71 | 70 | ||
72 | mutex_lock(&wl->mutex); | 71 | /* When RFKILL is registered, it will call back into this callback. |
72 | * wl->mutex will already be locked when this happens. | ||
73 | * So first trylock. On contention check if we are in initialization. | ||
74 | * Silently return if that happens to avoid a deadlock. */ | ||
75 | if (mutex_trylock(&wl->mutex) == 0) { | ||
76 | if (b43_status(dev) < B43_STAT_INITIALIZED) | ||
77 | return 0; | ||
78 | mutex_lock(&wl->mutex); | ||
79 | } | ||
73 | if (b43_status(dev) < B43_STAT_INITIALIZED) | 80 | if (b43_status(dev) < B43_STAT_INITIALIZED) |
74 | goto out_unlock; | 81 | goto out_unlock; |
75 | 82 | ||
@@ -89,7 +96,6 @@ static int b43_rfkill_soft_toggle(void *data, enum rfkill_state state) | |||
89 | b43_radio_turn_off(dev, 0); | 96 | b43_radio_turn_off(dev, 0); |
90 | break; | 97 | break; |
91 | } | 98 | } |
92 | |||
93 | out_unlock: | 99 | out_unlock: |
94 | mutex_unlock(&wl->mutex); | 100 | mutex_unlock(&wl->mutex); |
95 | 101 | ||