rfkill: Register LED triggers before registering switch
authorMichael Buesch <mb@bu3sch.de>
Sun, 28 Oct 2007 12:07:54 +0000 (13:07 +0100)
committerDavid S. Miller <davem@sunset.davemloft.net>
Sun, 11 Nov 2007 05:59:11 +0000 (21:59 -0800)
Registering the switch triggers a LED event, so we must register
LED triggers before the switch.
This has a potential to fix a crash, depending on how the device
driver initializes the rfkill data structure.

Signed-off-by: Michael Buesch <mb@bu3sch.de>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
net/rfkill/rfkill.c

index 51d151c0e9621169730881d3867fa70e50e20042..c6a9412fe5bd40efbf338dc310bc3467516430ac 100644 (file)
@@ -388,19 +388,20 @@ int rfkill_register(struct rfkill *rfkill)
        if (!rfkill->toggle_radio)
                return -EINVAL;
 
+       snprintf(dev->bus_id, sizeof(dev->bus_id),
+                "rfkill%ld", (long)atomic_inc_return(&rfkill_no) - 1);
+
+       rfkill_led_trigger_register(rfkill);
+
        error = rfkill_add_switch(rfkill);
        if (error)
                return error;
 
-       snprintf(dev->bus_id, sizeof(dev->bus_id),
-                "rfkill%ld", (long)atomic_inc_return(&rfkill_no) - 1);
-
        error = device_add(dev);
        if (error) {
                rfkill_remove_switch(rfkill);
                return error;
        }
-       rfkill_led_trigger_register(rfkill);
 
        return 0;
 }
@@ -416,9 +417,9 @@ EXPORT_SYMBOL(rfkill_register);
  */
 void rfkill_unregister(struct rfkill *rfkill)
 {
-       rfkill_led_trigger_unregister(rfkill);
        device_del(&rfkill->dev);
        rfkill_remove_switch(rfkill);
+       rfkill_led_trigger_unregister(rfkill);
        put_device(&rfkill->dev);
 }
 EXPORT_SYMBOL(rfkill_unregister);