aboutsummaryrefslogtreecommitdiffstats
path: root/net/rfkill
diff options
context:
space:
mode:
Diffstat (limited to 'net/rfkill')
-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,