From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Guangshuo Li <lgs201920130244@gmail.com>
Cc: Lee Jones <lee@kernel.org>, Pavel Machek <pavel@kernel.org>,
Sakari Ailus <sakari.ailus@linux.intel.com>,
Jonathan Cameron <jic23@kernel.org>,
Luca Weiss <luca@lucaweiss.eu>,
linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH] leds: flash: sgm3140: fix child node reference leak
Date: Mon, 14 Sep 2026 17:17:22 +0300 [thread overview]
Message-ID: <20260914141722.GD2522202@killaraus.ideasonboard.com> (raw)
In-Reply-To: <20260914135723.1741327-1-lgs201920130244@gmail.com>
On Mon, Sep 14, 2026 at 09:57:23PM +0800, Guangshuo Li wrote:
> sgm3140_probe() obtains a reference to the LED child node with
> device_get_next_child_node(). The probe error path correctly drops this
> reference with fwnode_handle_put(), but the successful probe path
> returns without releasing it.
>
> v4l2_flash_init() takes its own reference to the supplied fwnode and
> v4l2_flash_release() drops that reference during device removal.
How about devm_led_classdev_flash_register_ext() ?
> Therefore, the reference acquired by sgm3140_probe() is only needed
> during probe and can be released once initialization has completed.
>
> Drop the child node reference before returning successfully from probe.
>
> This issue was found by manual code inspection.
I wonder what prompted you to manual inspect that code.
> Fixes: cef8ec8cbd21 ("leds: add sgm3140 driver")
> Cc: stable@vger.kernel.org
> Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
> ---
> drivers/leds/flash/leds-sgm3140.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/leds/flash/leds-sgm3140.c b/drivers/leds/flash/leds-sgm3140.c
> index dc6840357370..51e31fdb78e5 100644
> --- a/drivers/leds/flash/leds-sgm3140.c
> +++ b/drivers/leds/flash/leds-sgm3140.c
> @@ -273,7 +273,9 @@ static int sgm3140_probe(struct platform_device *pdev)
> goto err;
> }
>
> - return ret;
> + fwnode_handle_put(child_node);
> +
> + return 0;
>
> err:
> fwnode_handle_put(child_node);
--
Regards,
Laurent Pinchart
next prev parent reply other threads:[~2026-09-14 14:17 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-14 13:57 [PATCH] leds: flash: sgm3140: fix child node reference leak Guangshuo Li
2026-09-14 14:17 ` Laurent Pinchart [this message]
2026-09-21 8:57 ` Guangshuo Li
2026-09-21 9:04 ` Laurent Pinchart
2026-09-14 14:25 ` sashiko-bot
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=20260914141722.GD2522202@killaraus.ideasonboard.com \
--to=laurent.pinchart@ideasonboard.com \
--cc=jic23@kernel.org \
--cc=lee@kernel.org \
--cc=lgs201920130244@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=luca@lucaweiss.eu \
--cc=pavel@kernel.org \
--cc=sakari.ailus@linux.intel.com \
--cc=stable@vger.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.