diff options
-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 | ||