[PATCH] leds: max77705: fix fwnode reference leak in max77705_add_led()

From: Manush Prajwal

Date: Fri Aug 28 2026 - 04:49:01 EST


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@xxxxxxxxx>
---
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