aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorMichael Buesch <mb@bu3sch.de>2007-11-28 11:49:34 -0500
committerJohn W. Linville <linville@tuxdriver.com>2007-11-29 18:08:48 -0500
commit7f4c534178722ac9ffb4feae3a4d54e3fbe3f22c (patch)
tree5067b23f30c5758bb6d6eee5e169afb98c98cd79 /net
parent8312512e81ab16d845b49d1ec695fad1c72f19f6 (diff)
rfkill: fix double-mutex-locking
rfkill_toggle_radio is called from functions where rfkill->mutex is already aquired. Remove the lock from rfkill_toggle_radio() and add it to the only calling function that calls it without the lock held. Signed-off-by: Michael Buesch <mb@bu3sch.de> Acked-by: Ivo van Doorn <IvDoorn@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net')
-rw-r--r--net/rfkill/rfkill.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/net/rfkill/rfkill.c b/net/rfkill/rfkill.c
index 73d60a307129..4469a7be006c 100644
--- a/net/rfkill/rfkill.c
+++ b/net/rfkill/rfkill.c
@@ -60,11 +60,7 @@ static void rfkill_led_trigger(struct rfkill *rfkill,
60static int rfkill_toggle_radio(struct rfkill *rfkill, 60static int rfkill_toggle_radio(struct rfkill *rfkill,
61 enum rfkill_state state) 61 enum rfkill_state state)
62{ 62{
63 int retval; 63 int retval = 0;
64
65 retval = mutex_lock_interruptible(&rfkill->mutex);
66 if (retval)
67 return retval;
68 64
69 if (state != rfkill->state) { 65 if (state != rfkill->state) {
70 retval = rfkill->toggle_radio(rfkill->data, state); 66 retval = rfkill->toggle_radio(rfkill->data, state);
@@ -74,7 +70,6 @@ static int rfkill_toggle_radio(struct rfkill *rfkill,
74 } 70 }
75 } 71 }
76 72
77 mutex_unlock(&rfkill->mutex);
78 return retval; 73 return retval;
79} 74}
80 75
@@ -158,12 +153,13 @@ static ssize_t rfkill_state_store(struct device *dev,
158 if (!capable(CAP_NET_ADMIN)) 153 if (!capable(CAP_NET_ADMIN))
159 return -EPERM; 154 return -EPERM;
160 155
156 if (mutex_lock_interruptible(&rfkill->mutex))
157 return -ERESTARTSYS;
161 error = rfkill_toggle_radio(rfkill, 158 error = rfkill_toggle_radio(rfkill,
162 state ? RFKILL_STATE_ON : RFKILL_STATE_OFF); 159 state ? RFKILL_STATE_ON : RFKILL_STATE_OFF);
163 if (error) 160 mutex_unlock(&rfkill->mutex);
164 return error;
165 161
166 return count; 162 return error ? error : count;
167} 163}
168 164
169static ssize_t rfkill_claim_show(struct device *dev, 165static ssize_t rfkill_claim_show(struct device *dev,