summaryrefslogtreecommitdiff
path: root/drivers/leds/rgb
diff options
context:
space:
mode:
authorLu Hongfei <luhongfei@vivo.com>2023-05-25 14:17:03 +0300
committerLee Jones <lee@kernel.org>2023-05-25 15:01:45 +0300
commit8f38f8fa7261819eb7d4fb369dc3bfab72259033 (patch)
tree7538076349e5ae8ac5dd93860704b85bf549953d /drivers/leds/rgb
parent28598e218076f77cbd44b7762aa5f935356aebd4 (diff)
downloadlinux-8f38f8fa7261819eb7d4fb369dc3bfab72259033.tar.xz
led: qcom-lpg: Fix resource leaks in for_each_available_child_of_node() loops
Ensure child node references are decremented properly in the error path. Signed-off-by: Lu Hongfei <luhongfei@vivo.com> Link: https://lore.kernel.org/r/20230525111705.3055-1-luhongfei@vivo.com Signed-off-by: Lee Jones <lee@kernel.org>
Diffstat (limited to 'drivers/leds/rgb')
-rw-r--r--drivers/leds/rgb/leds-qcom-lpg.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/leds/rgb/leds-qcom-lpg.c b/drivers/leds/rgb/leds-qcom-lpg.c
index c9cea797a697..20469200961f 100644
--- a/drivers/leds/rgb/leds-qcom-lpg.c
+++ b/drivers/leds/rgb/leds-qcom-lpg.c
@@ -1173,8 +1173,10 @@ static int lpg_add_led(struct lpg *lpg, struct device_node *np)
i = 0;
for_each_available_child_of_node(np, child) {
ret = lpg_parse_channel(lpg, child, &led->channels[i]);
- if (ret < 0)
+ if (ret < 0) {
+ of_node_put(child);
return ret;
+ }
info[i].color_index = led->channels[i]->color;
info[i].intensity = 0;
@@ -1352,8 +1354,10 @@ static int lpg_probe(struct platform_device *pdev)
for_each_available_child_of_node(pdev->dev.of_node, np) {
ret = lpg_add_led(lpg, np);
- if (ret)
+ if (ret) {
+ of_node_put(np);
return ret;
+ }
}
for (i = 0; i < lpg->num_channels; i++)