提交 37f55e9d 编写于 作者: H Henrique de Moraes Holschuh 提交者: John W. Linville

rfkill: fix led-trigger unregister order in error unwind

rfkill needs to unregister the led trigger AFTER a call to
rfkill_remove_switch(), otherwise it will not update the LED state,
possibly leaving it ON when it should be OFF.

To make led-trigger unregistering safer, guard against unregistering a
trigger twice, and also against issuing trigger events to a led trigger
that was unregistered.  This makes the error unwind paths more resilient.

Refer to "rfkill: Register LED triggers before registering switch".
Signed-off-by: NHenrique de Moraes Holschuh <hmh@hmh.eng.br>
Acked-by: NIvo van Doorn <IvDoorn@gmail.com>
Cc: Michael Buesch <mb@bu3sch.de>
Cc: Dmitry Baryshkov <dbaryshkov@gmail.com>
Signed-off-by: NJohn W. Linville <linville@tuxdriver.com>
上级 2fd9b221
......@@ -590,8 +590,10 @@ static void rfkill_led_trigger_register(struct rfkill *rfkill)
static void rfkill_led_trigger_unregister(struct rfkill *rfkill)
{
#ifdef CONFIG_RFKILL_LEDS
if (rfkill->led_trigger.name)
if (rfkill->led_trigger.name) {
led_trigger_unregister(&rfkill->led_trigger);
rfkill->led_trigger.name = NULL;
}
#endif
}
......@@ -627,8 +629,8 @@ int rfkill_register(struct rfkill *rfkill)
error = device_add(dev);
if (error) {
rfkill_led_trigger_unregister(rfkill);
rfkill_remove_switch(rfkill);
rfkill_led_trigger_unregister(rfkill);
return error;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册