Commit 2c677562 authored by Marek Behún's avatar Marek Behún Committed by Pavel Machek

leds: various: fix OF node leaks

Fix OF node leaks by calling of_node_put in
for_each_available_child_of_node when the cycle breaks or returns.
Signed-off-by: default avatarMarek Behún <marek.behun@nic.cz>
Cc: Nikita Travkin <nikitos.tr@gmail.com>
Cc: Milo Kim <milo.kim@ti.com>
Cc: Dan Murphy <dmurphy@ti.com>
Signed-off-by: default avatarPavel Machek <pavel@ucw.cz>
Not-for-stable: untested, theoretical, insignificant leaks
parent 99a013c8
......@@ -305,8 +305,10 @@ static int aw2013_probe_dt(struct aw2013 *chip)
ret = devm_led_classdev_register_ext(&chip->client->dev,
&led->cdev, &init_data);
if (ret < 0)
if (ret < 0) {
of_node_put(child);
return ret;
}
i++;
}
......
......@@ -614,8 +614,10 @@ static int lp55xx_parse_multi_led(struct device_node *np,
for_each_available_child_of_node(np, child) {
ret = lp55xx_parse_multi_led_child(child, cfg, child_number,
num_colors);
if (ret)
if (ret) {
of_node_put(child);
return ret;
}
num_colors++;
}
......@@ -681,8 +683,10 @@ struct lp55xx_platform_data *lp55xx_of_populate_pdata(struct device *dev,
for_each_available_child_of_node(np, child) {
ret = lp55xx_parse_logical_led(child, cfg, i);
if (ret)
if (ret) {
of_node_put(child);
return ERR_PTR(-EINVAL);
}
i++;
}
......
......@@ -236,8 +236,10 @@ static int omnia_leds_probe(struct i2c_client *client,
led = &leds->leds[0];
for_each_available_child_of_node(np, child) {
ret = omnia_led_register(client, led, child);
if (ret < 0)
if (ret < 0) {
of_node_put(child);
return ret;
}
led += ret;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment