mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] leds: max77705: fix fwnode reference leak in max77705_add_led()
@ 2026-08-28  8:46 Manush Prajwal
  2026-08-28  8:56 ` Krzysztof Kozlowski
  0 siblings, 1 reply; 2+ messages in thread
From: Manush Prajwal @ 2026-08-28  8:46 UTC (permalink / raw)
  To: cw00.choi, krzk, lee, pavel
  Cc: linux-leds, linux-kernel, dsankouski, sakari.ailus

In the RGB LED path of max77705_add_led(), the
fwnode_for_each_child_node() loop over the subled child nodes
returns directly on a max77705_parse_subled() failure without
releasing the reference held on the current child, since
fwnode_for_each_child_node() is not a scoped/cleanup-based
iterator and expects the caller to drop the reference itself on
any early exit from the loop body.

Call fwnode_handle_put() on the child fwnode before returning to
fix the leak.

Fixes: 3b6eaa3db567 ("leds: Use fwnode_for_each_child_node() instead")
Signed-off-by: Manush Prajwal <manushprajwal555@gmail.com>
---
 drivers/leds/leds-max77705.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/leds/leds-max77705.c b/drivers/leds/leds-max77705.c
index 1e2054c..a5030c3 100644
--- a/drivers/leds/leds-max77705.c
+++ b/drivers/leds/leds-max77705.c
@@ -193,8 +193,10 @@ static int max77705_add_led(struct device *dev, struct regmap *regmap, struct fw

 		fwnode_for_each_child_node(np, child) {
 			ret = max77705_parse_subled(dev, child, &info[i]);
-			if (ret < 0)
+			if (ret < 0) {
+				fwnode_handle_put(child);
 				return ret;
+			}

 			info[i].intensity = 0;
 			i++;
--
2.46.2.windows.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] leds: max77705: fix fwnode reference leak in max77705_add_led()
  2026-08-28  8:46 [PATCH] leds: max77705: fix fwnode reference leak in max77705_add_led() Manush Prajwal
@ 2026-08-28  8:56 ` Krzysztof Kozlowski
  0 siblings, 0 replies; 2+ messages in thread
From: Krzysztof Kozlowski @ 2026-08-28  8:56 UTC (permalink / raw)
  To: Manush Prajwal, cw00.choi, lee, pavel
  Cc: linux-leds, linux-kernel, dsankouski, sakari.ailus

On 28/08/2026 10:46, Manush Prajwal wrote:
> In the RGB LED path of max77705_add_led(), the
> fwnode_for_each_child_node() loop over the subled child nodes
> returns directly on a max77705_parse_subled() failure without
> releasing the reference held on the current child, since
> fwnode_for_each_child_node() is not a scoped/cleanup-based
> iterator and expects the caller to drop the reference itself on
> any early exit from the loop body.
> 
> Call fwnode_handle_put() on the child fwnode before returning to
> fix the leak.
> 
> Fixes: 3b6eaa3db567 ("leds: Use fwnode_for_each_child_node() instead")
> Signed-off-by: Manush Prajwal <manushprajwal555@gmail.com>
> ---
>  drivers/leds/leds-max77705.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/leds/leds-max77705.c b/drivers/leds/leds-max77705.c
> index 1e2054c..a5030c3 100644
> --- a/drivers/leds/leds-max77705.c
> +++ b/drivers/leds/leds-max77705.c
> @@ -193,8 +193,10 @@ static int max77705_add_led(struct device *dev, struct regmap *regmap, struct fw
> 
>  		fwnode_for_each_child_node(np, child) {

Would fwnode_for_each_child_node_scoped() work here?

>  			ret = max77705_parse_subled(dev, child, &info[i]);
> -			if (ret < 0)
> +			if (ret < 0) {
> +				fwnode_handle_put(child);
>  				return ret;
> +			}
> 
Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-08-28  8:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-28  8:46 [PATCH] leds: max77705: fix fwnode reference leak in max77705_add_led() Manush Prajwal
2026-08-28  8:56 ` Krzysztof Kozlowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®