Skip to contentSkip to conversation

leds-gpio: fix possible crash on OF device unbinding

PATCH New Dmitry Eremin-Solenikov 1 participant 1 message Nov 15, 2009 LED

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 drivers/leds/leds-gpio.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/leds/leds-gpio.c +2 -0
index 7467980..e5225d2 100644
@@ -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",
Signature · 1 line
1.6.5