* [PATCH] led: qcom-lpg: Fix resource leaks in for_each_available_child_of_node() loops
@ 2023-05-25 11:17 Lu Hongfei
2023-05-25 12:02 ` Lee Jones
0 siblings, 1 reply; 2+ messages in thread
From: Lu Hongfei @ 2023-05-25 11:17 UTC (permalink / raw)
To: Pavel Machek, Lee Jones, Anjelique Melendez, Thierry Reding,
Conor Dooley, Uwe Kleine-König, Dmitry Baryshkov,
Lu Hongfei, open list:LED SUBSYSTEM, open list
Cc: opensource.kernel, luhongfei
for_each_available_child_of_node in lpg_probe and lpg_add_led need
to execute of_node_put before return. this patch could fix this bug.
Signed-off-by: Lu Hongfei <luhongfei@vivo.com>
---
drivers/leds/rgb/leds-qcom-lpg.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
mode change 100644 => 100755 drivers/leds/rgb/leds-qcom-lpg.c
diff --git a/drivers/leds/rgb/leds-qcom-lpg.c b/drivers/leds/rgb/leds-qcom-lpg.c
index 55a037234df1..0e8ff36c4bf7
--- 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++)
--
2.39.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] led: qcom-lpg: Fix resource leaks in for_each_available_child_of_node() loops
2023-05-25 11:17 [PATCH] led: qcom-lpg: Fix resource leaks in for_each_available_child_of_node() loops Lu Hongfei
@ 2023-05-25 12:02 ` Lee Jones
0 siblings, 0 replies; 2+ messages in thread
From: Lee Jones @ 2023-05-25 12:02 UTC (permalink / raw)
To: Lu Hongfei
Cc: Pavel Machek, Anjelique Melendez, Thierry Reding, Conor Dooley,
Uwe Kleine-König, Dmitry Baryshkov, Lu Hongfei,
open list:LED SUBSYSTEM, open list, opensource.kernel
On Thu, 25 May 2023, Lu Hongfei wrote:
> for_each_available_child_of_node in lpg_probe and lpg_add_led need
> to execute of_node_put before return. this patch could fix this bug.
>
> Signed-off-by: Lu Hongfei <luhongfei@vivo.com>
> ---
> drivers/leds/rgb/leds-qcom-lpg.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
> mode change 100644 => 100755 drivers/leds/rgb/leds-qcom-lpg.c
I made a few tweaks to the commit messaged.
Applied, thanks
--
Lee Jones [李琼斯]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-05-25 12:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-25 11:17 [PATCH] led: qcom-lpg: Fix resource leaks in for_each_available_child_of_node() loops Lu Hongfei
2023-05-25 12:02 ` Lee Jones
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).