leds-gpio: fix possible crash on OF device unbinding
authorDmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Sun, 15 Nov 2009 22:48:32 +0000 (01:48 +0300)
committerRichard Purdie <rpurdie@linux.intel.com>
Mon, 16 Nov 2009 11:50:42 +0000 (11:50 +0000)
If there are leds present in the OF tree, but the GPIOs for (some) of
them are unavailable, led_data doesn't get populated with correct
devices. Then, on device unbinding, one can crash the kernel.

Workaround this by setting led->gpio to invalid value early.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
drivers/leds/leds-gpio.c

index 7467980b8cf975dd92758c13d57d189322b2a6f2..e5225d28f39245cbff44373f38947e3839847a6f 100644 (file)
@@ -78,6 +78,8 @@ static int __devinit create_gpio_led(const struct gpio_led *template,
 {
        int ret, state;
 
+       led_dat->gpio = -1;
+
        /* skip leds that aren't available */
        if (!gpio_is_valid(template->gpio)) {
                printk(KERN_INFO "Skipping unavailable LED gpio %d (%s)\n",