mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Lee Jones <lee@kernel.org>
To: mileskrause5200@gmail.com
Cc: Chanwoo Choi <cw00.choi@samsung.com>,
	Krzysztof Kozlowski <krzk@kernel.org>,
	Pavel Machek <pavel@kernel.org>,
	Dzmitry Sankouski <dsankouski@gmail.com>,
	linux-kernel@vger.kernel.org, linux-leds@vger.kernel.org
Subject: Re: [PATCH] leds: max77705: fix fwnode reference leak in max77705_add_led()
Date: Thu, 17 Sep 2026 14:25:19 +0100	[thread overview]
Message-ID: <20260917132519.GK1605367@google.com> (raw)
In-Reply-To: <20260906-leds-max77705-fwnode-leak-v1-1-eba6822529fd@gmail.com>

On Sun, 06 Sep 2026, Miles Krause via B4 Relay wrote:

> From: Miles Krause <mileskrause5200@gmail.com>
> 
> max77705_add_led() iterates over the multicolor LED's child nodes with
> fwnode_for_each_child_node() and returns directly from inside the loop
> when parsing a child fails:
> 
> 	fwnode_for_each_child_node(np, child) {
> 		ret = max77705_parse_subled(dev, child, &info[i]);
> 		if (ret < 0)
> 			return ret;
> 		...
> 	}
> 
> The iterator holds a reference on the current child for the duration of
> each iteration: fwnode_get_next_child_node() takes a reference on the
> node it returns and only drops the previous one when it is called again
> (for the OF backend that is the of_node_put(prev) in
> of_get_next_status_child()).  Returning from inside the loop skips that
> final call, so the reference taken for the child that failed to parse is
> never released.
> 
> max77705_parse_subled() rejects a missing, zero or out-of-range "reg"
> property and propagates errors from reading "color", so a malformed
> device tree is enough to leak a device_node reference.
> 
> Use fwnode_for_each_child_node_scoped() instead, which releases the
> reference on every exit path, and drop the now unused 'child'
> declaration.  max77705_led_probe() already uses the equivalent
> device_for_each_child_node_scoped() for the outer loop.
> 
> Fixes: aebb5fc9a0d8 ("leds: max77705: Add LEDs support")
> Signed-off-by: Miles Krause <mileskrause5200@gmail.com>

Beaten to it by this I'm afraid:

  4805e5ec50d0 leds: max77705: Use fwnode_for_each_child_node_scoped() in max77705_add_led()

-- 
Lee Jones

  reply	other threads:[~2026-09-17 13:25 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-06 19:11 Miles Krause via B4 Relay
2026-09-17 13:25 ` Lee Jones [this message]
  -- strict thread matches above, loose matches on Subject: below --
2026-08-28  8:46 Manush Prajwal
2026-08-28  8:56 ` Krzysztof Kozlowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260917132519.GK1605367@google.com \
    --to=lee@kernel.org \
    --cc=cw00.choi@samsung.com \
    --cc=dsankouski@gmail.com \
    --cc=krzk@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=mileskrause5200@gmail.com \
    --cc=pavel@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®