Skip to content

Commit

Permalink
leds: lgm-sso: Put fwnode in any case during ->probe()
Browse files Browse the repository at this point in the history
[ Upstream commit 9999908 ]

fwnode_get_next_child_node() bumps a reference counting of a returned variable.
We have to balance it whenever we return to the caller.

All the same in fwnode_for_each_child_node() case.

Fixes: c3987cd ("leds: lgm: Add LED controller driver for LGM SoC")
Cc: Amireddy Mallikarjuna reddy <mallikarjunax.reddy@linux.intel.com>
Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
andy-shev authored and gregkh committed Sep 15, 2021
1 parent 3cae429 commit 129d481
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions drivers/leds/blink/leds-lgm-sso.c
Expand Up @@ -631,8 +631,10 @@ __sso_led_dt_parse(struct sso_led_priv *priv, struct fwnode_handle *fw_ssoled)

fwnode_for_each_child_node(fw_ssoled, fwnode_child) {
led = devm_kzalloc(dev, sizeof(*led), GFP_KERNEL);
if (!led)
return -ENOMEM;
if (!led) {
ret = -ENOMEM;
goto __dt_err;
}

INIT_LIST_HEAD(&led->list);
led->priv = priv;
Expand Down Expand Up @@ -702,11 +704,11 @@ __sso_led_dt_parse(struct sso_led_priv *priv, struct fwnode_handle *fw_ssoled)
if (sso_create_led(priv, led, fwnode_child))
goto __dt_err;
}
fwnode_handle_put(fw_ssoled);

return 0;

__dt_err:
fwnode_handle_put(fw_ssoled);
fwnode_handle_put(fwnode_child);
/* unregister leds */
list_for_each(p, &priv->led_list) {
led = list_entry(p, struct sso_led, list);
Expand All @@ -731,6 +733,7 @@ static int sso_led_dt_parse(struct sso_led_priv *priv)
fw_ssoled = fwnode_get_named_child_node(fwnode, "ssoled");
if (fw_ssoled) {
ret = __sso_led_dt_parse(priv, fw_ssoled);
fwnode_handle_put(fw_ssoled);
if (ret)
return ret;
}
Expand Down

0 comments on commit 129d481

Please sign in to comment.