From: Jacek Anaszewski Date: Thu, 16 Apr 2015 07:30:50 +0000 (-0700) Subject: leds: gpio: Fix error handling for led name null pointer case X-Git-Tag: v5.15~15508^2~29 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0e14e0bfe85dd22ba19446bdfdc2cf0e941b9731;p=platform%2Fkernel%2Flinux-starfive.git 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 --- diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c index 25df4a2..c3db74a 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);