Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: 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

authored by

Marek Behún and committed by
Pavel Machek
2c677562 99a013c8

+12 -4
+3 -1
drivers/leds/leds-aw2013.c
··· 305 305 306 306 ret = devm_led_classdev_register_ext(&chip->client->dev, 307 307 &led->cdev, &init_data); 308 - if (ret < 0) 308 + if (ret < 0) { 309 + of_node_put(child); 309 310 return ret; 311 + } 310 312 311 313 i++; 312 314 }
+6 -2
drivers/leds/leds-lp55xx-common.c
··· 614 614 for_each_available_child_of_node(np, child) { 615 615 ret = lp55xx_parse_multi_led_child(child, cfg, child_number, 616 616 num_colors); 617 - if (ret) 617 + if (ret) { 618 + of_node_put(child); 618 619 return ret; 620 + } 619 621 num_colors++; 620 622 } 621 623 ··· 683 681 684 682 for_each_available_child_of_node(np, child) { 685 683 ret = lp55xx_parse_logical_led(child, cfg, i); 686 - if (ret) 684 + if (ret) { 685 + of_node_put(child); 687 686 return ERR_PTR(-EINVAL); 687 + } 688 688 i++; 689 689 } 690 690
+3 -1
drivers/leds/leds-turris-omnia.c
··· 236 236 led = &leds->leds[0]; 237 237 for_each_available_child_of_node(np, child) { 238 238 ret = omnia_led_register(client, led, child); 239 - if (ret < 0) 239 + if (ret < 0) { 240 + of_node_put(child); 240 241 return ret; 242 + } 241 243 242 244 led += ret; 243 245 }