]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
leds: various: fix OF node leaks
authorMarek Behún <marek.behun@nic.cz>
Thu, 17 Sep 2020 22:32:57 +0000 (00:32 +0200)
committerPavel Machek <pavel@ucw.cz>
Sat, 26 Sep 2020 19:56:39 +0000 (21:56 +0200)
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: Marek 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: Pavel Machek <pavel@ucw.cz>
Not-for-stable: untested, theoretical, insignificant leaks

drivers/leds/leds-aw2013.c
drivers/leds/leds-lp55xx-common.c
drivers/leds/leds-turris-omnia.c

index 9df7de042bca2412c19b01878f3aadefbd649a98..927c5ba32592fc7fd1e0e6109d5b8a4279ec0bc1 100644 (file)
@@ -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++;
        }
index 50f7f5b874636202df15dde2d68e39ae35718170..81de1346bf5d670caab9962d1bab23745677ca54 100644 (file)
@@ -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++;
        }
 
index ea7da8517220d5ce40e915534d73742d85e00961..117976cf75c8aedbb68af85d1bb4a6d17a7afbcc 100644 (file)
@@ -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;
        }