From: Dmitry Eremin-Solenikov Date: Sun, 15 Nov 2009 22:48:32 +0000 (+0300) Subject: leds-gpio: fix possible crash on OF device unbinding X-Git-Tag: v2.6.32-rc8~30^2 X-Git-Url: http://git.samba.org/samba.git/?p=sfrench%2Fcifs-2.6.git;a=commitdiff_plain;h=0b4634fce1f3f7028421630260d54093276db490;ds=sidebyside leds-gpio: fix possible crash on OF device unbinding 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 Signed-off-by: Richard Purdie --- diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c index 7467980b8cf9..e5225d28f392 100644 --- a/drivers/leds/leds-gpio.c +++ b/drivers/leds/leds-gpio.c @@ -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",