leds: lgm-sso: Put fwnode in any case during ->probe()

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: c3987cd2bc ("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>
This commit is contained in:
Andy Shevchenko 2021-05-29 14:19:26 +03:00 committed by Pavel Machek
parent e06ba23b05
commit 9999908ca1

View File

@ -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;
@ -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);
@ -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;
}