mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00
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>
This commit is contained in:
parent
99be74f61c
commit
2f39f68cec
1 changed files with 2 additions and 5 deletions
|
@ -586,7 +586,6 @@ static int lm3532_parse_node(struct lm3532_data *priv)
|
||||||
ret = fwnode_property_read_u32(child, "reg", &control_bank);
|
ret = fwnode_property_read_u32(child, "reg", &control_bank);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(&priv->client->dev, "reg property missing\n");
|
dev_err(&priv->client->dev, "reg property missing\n");
|
||||||
fwnode_handle_put(child);
|
|
||||||
goto child_out;
|
goto child_out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -601,7 +600,6 @@ static int lm3532_parse_node(struct lm3532_data *priv)
|
||||||
&led->mode);
|
&led->mode);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(&priv->client->dev, "ti,led-mode property missing\n");
|
dev_err(&priv->client->dev, "ti,led-mode property missing\n");
|
||||||
fwnode_handle_put(child);
|
|
||||||
goto child_out;
|
goto child_out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -636,7 +634,6 @@ static int lm3532_parse_node(struct lm3532_data *priv)
|
||||||
led->num_leds);
|
led->num_leds);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(&priv->client->dev, "led-sources property missing\n");
|
dev_err(&priv->client->dev, "led-sources property missing\n");
|
||||||
fwnode_handle_put(child);
|
|
||||||
goto child_out;
|
goto child_out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -647,7 +644,6 @@ static int lm3532_parse_node(struct lm3532_data *priv)
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(&priv->client->dev, "led register err: %d\n",
|
dev_err(&priv->client->dev, "led register err: %d\n",
|
||||||
ret);
|
ret);
|
||||||
fwnode_handle_put(child);
|
|
||||||
goto child_out;
|
goto child_out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -655,14 +651,15 @@ static int lm3532_parse_node(struct lm3532_data *priv)
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(&priv->client->dev, "register init err: %d\n",
|
dev_err(&priv->client->dev, "register init err: %d\n",
|
||||||
ret);
|
ret);
|
||||||
fwnode_handle_put(child);
|
|
||||||
goto child_out;
|
goto child_out;
|
||||||
}
|
}
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
|
|
||||||
child_out:
|
child_out:
|
||||||
|
fwnode_handle_put(child);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue