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>
This commit is contained in:
committed by
John W. Linville
parent
8312512e81
commit
7f4c534178
@ -60,11 +60,7 @@ static void rfkill_led_trigger(struct rfkill *rfkill,
|
|||||||
static int rfkill_toggle_radio(struct rfkill *rfkill,
|
static int rfkill_toggle_radio(struct rfkill *rfkill,
|
||||||
enum rfkill_state state)
|
enum rfkill_state state)
|
||||||
{
|
{
|
||||||
int retval;
|
int retval = 0;
|
||||||
|
|
||||||
retval = mutex_lock_interruptible(&rfkill->mutex);
|
|
||||||
if (retval)
|
|
||||||
return retval;
|
|
||||||
|
|
||||||
if (state != rfkill->state) {
|
if (state != rfkill->state) {
|
||||||
retval = rfkill->toggle_radio(rfkill->data, state);
|
retval = rfkill->toggle_radio(rfkill->data, state);
|
||||||
@ -74,7 +70,6 @@ static int rfkill_toggle_radio(struct rfkill *rfkill,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex_unlock(&rfkill->mutex);
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,12 +153,13 @@ static ssize_t rfkill_state_store(struct device *dev,
|
|||||||
if (!capable(CAP_NET_ADMIN))
|
if (!capable(CAP_NET_ADMIN))
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
|
|
||||||
|
if (mutex_lock_interruptible(&rfkill->mutex))
|
||||||
|
return -ERESTARTSYS;
|
||||||
error = rfkill_toggle_radio(rfkill,
|
error = rfkill_toggle_radio(rfkill,
|
||||||
state ? RFKILL_STATE_ON : RFKILL_STATE_OFF);
|
state ? RFKILL_STATE_ON : RFKILL_STATE_OFF);
|
||||||
if (error)
|
mutex_unlock(&rfkill->mutex);
|
||||||
return error;
|
|
||||||
|
|
||||||
return count;
|
return error ? error : count;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t rfkill_claim_show(struct device *dev,
|
static ssize_t rfkill_claim_show(struct device *dev,
|
||||||
|
Reference in New Issue
Block a user