From: Lee Jones <lee@kernel.org>
To: Manush Prajwal <manushprajwal555@gmail.com>
Cc: pavel@kernel.org, dmurphy@ti.com, linux-leds@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] leds: lp50xx: use scoped loop to fix fwnode reference leak in lp50xx_probe_dt()
Date: Thu, 15 Oct 2026 16:31:49 +0100 [thread overview]
Message-ID: <20261015153149.GC2048969@google.com> (raw)
In-Reply-To: <6abde533.1f5d5c08.1fd03.f4e7@mx.google.com>
On Thu, 01 Oct 2026, Manush Prajwal wrote:
> In lp50xx_probe_dt(), fwnode_for_each_child_node(child, led_node) iterates
> over each sub-LED child node. If fwnode_property_read_u32() for "reg" fails
> or if multi_index >= LP50XX_LEDS_PER_MODULE, the function returns -EINVAL
> without dropping the reference count of led_node, leaking the fwnode.
>
> Use fwnode_for_each_child_node_scoped() to automatically release led_node
> on all exit paths, eliminating the refcount leak as well as the manual
> fwnode_handle_put(led_node) on the "color" property failure path, and
> remove the now unnecessary function-scope led_node variable declaration.
>
> Fixes: 193910c2c54e ("leds: lp50xx: Add the LP50XX family of the RGB LED driver")
This doesn't appear to be a real commit.
> Signed-off-by: Manush Prajwal <manushprajwal555@gmail.com>
> ---
> drivers/leds/leds-lp50xx.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/leds/leds-lp50xx.c b/drivers/leds/leds-lp50xx.c
> index 20bfb315b..d542eedd4 100644
> --- a/drivers/leds/leds-lp50xx.c
> +++ b/drivers/leds/leds-lp50xx.c
> @@ -458,7 +458,6 @@ static int lp50xx_probe_leds(struct fwnode_handle *child, struct lp50xx *priv,
>
> static int lp50xx_probe_dt(struct lp50xx *priv)
> {
> - struct fwnode_handle *led_node = NULL;
> struct led_init_data init_data = {};
> struct led_classdev *led_cdev;
> struct mc_subled *mc_led_info;
> @@ -505,12 +504,11 @@ static int lp50xx_probe_dt(struct lp50xx *priv)
> if (!mc_led_info)
> return -ENOMEM;
>
> - fwnode_for_each_child_node(child, led_node) {
> + fwnode_for_each_child_node_scoped(child, led_node) {
> int multi_index;
> ret = fwnode_property_read_u32(led_node, "color",
> &color_id);
> if (ret) {
> - fwnode_handle_put(led_node);
> dev_err(priv->dev, "Cannot read color\n");
> return ret;
> }
> --
> 2.46.2.windows.1
>
>
>
--
Lee Jones
prev parent reply other threads:[~2026-10-15 15:31 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-01 4:44 [PATCH] leds: lp50xx: use scoped loop to fix fwnode reference leak in lp50xx_probe_dt() Manush Prajwal
2026-10-01 4:52 ` sashiko-bot
2026-10-02 12:40 ` Griffin Kroah-Hartman
2026-10-15 15:31 ` Lee Jones [this message]
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=20261015153149.GC2048969@google.com \
--to=lee@kernel.org \
--cc=dmurphy@ti.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=manushprajwal555@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.