From 0e14e0bfe85dd22ba19446bdfdc2cf0e941b9731 Mon Sep 17 00:00:00 2001 From: Jacek Anaszewski Date: Thu, 16 Apr 2015 00:30:50 -0700 Subject: [PATCH] leds: gpio: Fix error handling for led name null pointer case 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 Cc: Richard Purdie Signed-off-by: Bryan Wu --- drivers/leds/leds-gpio.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c index 25df4a240972..c3db74a1aba7 100644 --- a/drivers/leds/leds-gpio.c +++ b/drivers/leds/leds-gpio.c @@ -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); -- 2.39.5