Skip to content

Commit

Permalink
leds: lm3532: Make error handling more robust
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Andy Shevchenko authored and Pavel Machek committed May 28, 2021
1 parent 99be74f commit 2f39f68
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions drivers/leds/leds-lm3532.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand All @@ -647,22 +644,22 @@ 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;
}

ret = lm3532_init_registers(led);
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;
}

Expand Down

0 comments on commit 2f39f68

Please sign in to comment.