Skip to content

Commit

Permalink
leds-gpio: fix possible crash on OF device unbinding
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Dmitry Eremin-Solenikov authored and Richard Purdie committed Nov 16, 2009
1 parent 716bdf1 commit 0b4634f
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/leds/leds-gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 0b4634f

Please sign in to comment.