leds: gpio: Fix error handling for led name null pointer case
authorJacek Anaszewski <j.anaszewski@samsung.com>
Thu, 16 Apr 2015 07:30:50 +0000 (00:30 -0700)
committerBryan Wu <cooloney@gmail.com>
Mon, 4 May 2015 18:05:55 +0000 (11:05 -0700)
Make sure that already registered LEDs will be torn down properly
if the name of the next LED to create is unavailable.

Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Cc: Richard Purdie <rpurdie@rpsys.net>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
drivers/leds/leds-gpio.c

index 25df4a24097216a727c9c7c630dd9f8d244423d8..c3db74a1aba7d4a3013c794e51cea0bba121ca34 100644 (file)
@@ -198,8 +198,10 @@ static struct gpio_leds_priv *gpio_leds_create(struct platform_device *pdev)
                } else {
                        if (IS_ENABLED(CONFIG_OF) && !led.name && np)
                                led.name = np->name;
-                       if (!led.name)
-                               return ERR_PTR(-EINVAL);
+                       if (!led.name) {
+                               ret = -EINVAL;
+                               goto err;
+                       }
                }
                fwnode_property_read_string(child, "linux,default-trigger",
                                            &led.default_trigger);