summaryrefslogtreecommitdiff
path: root/drivers/leds
diff options
context:
space:
mode:
authorAndy Shevchenko <andy.shevchenko@gmail.com>2021-05-10 12:50:21 +0300
committerPavel Machek <pavel@ucw.cz>2021-05-28 12:05:29 +0200
commite1012160bbbca92d67c729f68108734b7d679db9 (patch)
treea264f8b9b6a758fd54dcdb656c1a210730648b37 /drivers/leds
parent95138e01275e1af3f1fc2780fe1d9c6138b29c7a (diff)
leds: el15203000: Make error handling more robust
It's easy to miss necessary clean up, e.g. firmware node reference counting, during error path in ->probe(). Make it more robust by moving to a single point of return. Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Pavel Machek <pavel@ucw.cz>
Diffstat (limited to 'drivers/leds')
-rw-r--r--drivers/leds/leds-el15203000.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/drivers/leds/leds-el15203000.c b/drivers/leds/leds-el15203000.c
index c82f5d11e16c..76b455e87574 100644
--- a/drivers/leds/leds-el15203000.c
+++ b/drivers/leds/leds-el15203000.c
@@ -245,16 +245,13 @@ static int el15203000_probe_dt(struct el15203000 *priv)
ret = fwnode_property_read_u32(child, "reg", &led->reg);
if (ret) {
dev_err(priv->dev, "LED without ID number");
- fwnode_handle_put(child);
-
- break;
+ goto err_child_out;
}
if (led->reg > U8_MAX) {
dev_err(priv->dev, "LED value %d is invalid", led->reg);
- fwnode_handle_put(child);
-
- return -EINVAL;
+ ret = -EINVAL;
+ goto err_child_out;
}
led->priv = priv;
@@ -276,14 +273,16 @@ static int el15203000_probe_dt(struct el15203000 *priv)
dev_err(priv->dev,
"failed to register LED device %s, err %d",
led->ldev.name, ret);
- fwnode_handle_put(child);
-
- break;
+ goto err_child_out;
}
led++;
}
+ return 0;
+
+err_child_out:
+ fwnode_handle_put(child);
return ret;
}