diff options
-rw-r--r-- | drivers/leds/leds-gpio.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c index 15eb3f86f670..25df4a240972 100644 --- a/drivers/leds/leds-gpio.c +++ b/drivers/leds/leds-gpio.c @@ -217,18 +217,19 @@ static struct gpio_leds_priv *gpio_leds_create(struct platform_device *pdev) if (fwnode_property_present(child, "retain-state-suspended")) led.retain_state_suspended = 1; - ret = create_gpio_led(&led, &priv->leds[priv->num_leds++], + ret = create_gpio_led(&led, &priv->leds[priv->num_leds], dev, NULL); if (ret < 0) { fwnode_handle_put(child); goto err; } + priv->num_leds++; } return priv; err: - for (count = priv->num_leds - 2; count >= 0; count--) + for (count = priv->num_leds - 1; count >= 0; count--) delete_gpio_led(&priv->leds[count]); return ERR_PTR(ret); } |