summaryrefslogtreecommitdiffstats
path: root/drivers/leds/leds-lm3532.c
diff options
context:
space:
mode:
authorAndy Shevchenko <andy.shevchenko@gmail.com>2021-05-10 11:50:32 +0200
committerPavel Machek <pavel@ucw.cz>2021-05-28 12:00:13 +0200
commit2f39f68cec0a19c0371c1e7cb149159810e87f64 (patch)
treefdc69ec3acd8841aaaca429086603341f938c4cc /drivers/leds/leds-lm3532.c
parentleds: lm3532: select regmap I2C API (diff)
downloadlinux-2f39f68cec0a19c0371c1e7cb149159810e87f64.tar.xz
linux-2f39f68cec0a19c0371c1e7cb149159810e87f64.zip
leds: lm3532: 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 '')
-rw-r--r--drivers/leds/leds-lm3532.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/drivers/leds/leds-lm3532.c b/drivers/leds/leds-lm3532.c
index 0bf25bdde02f..beb53040e09e 100644
--- a/drivers/leds/leds-lm3532.c
+++ b/drivers/leds/leds-lm3532.c
@@ -586,7 +586,6 @@ static int lm3532_parse_node(struct lm3532_data *priv)
ret = fwnode_property_read_u32(child, "reg", &control_bank);
if (ret) {
dev_err(&priv->client->dev, "reg property missing\n");
- fwnode_handle_put(child);
goto child_out;
}
@@ -601,7 +600,6 @@ static int lm3532_parse_node(struct lm3532_data *priv)
&led->mode);
if (ret) {
dev_err(&priv->client->dev, "ti,led-mode property missing\n");
- fwnode_handle_put(child);
goto child_out;
}
@@ -636,7 +634,6 @@ static int lm3532_parse_node(struct lm3532_data *priv)
led->num_leds);
if (ret) {
dev_err(&priv->client->dev, "led-sources property missing\n");
- fwnode_handle_put(child);
goto child_out;
}
@@ -647,7 +644,6 @@ static int lm3532_parse_node(struct lm3532_data *priv)
if (ret) {
dev_err(&priv->client->dev, "led register err: %d\n",
ret);
- fwnode_handle_put(child);
goto child_out;
}
@@ -655,14 +651,15 @@ static int lm3532_parse_node(struct lm3532_data *priv)
if (ret) {
dev_err(&priv->client->dev, "register init err: %d\n",
ret);
- fwnode_handle_put(child);
goto child_out;
}
i++;
}
+ return 0;
child_out:
+ fwnode_handle_put(child);
return ret;
}