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-Url: https://git.stricted.de/?a=commitdiff_plain;h=0e14e0bfe85dd22ba19446bdfdc2cf0e941b9731;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.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 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);