From: Yige Jiang <yigejiang86@gmail.com>
To: linux-leds@vger.kernel.org
Cc: Lee Jones <lee@kernel.org>, Pavel Machek <pavel@kernel.org>,
Griffin Kroah-Hartman <griffin@kroah.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH] leds: pwm-multicolor: manage the multi-led node reference
Date: Fri, 30 Oct 2026 09:39:37 +0800 [thread overview]
Message-ID: <rc-review-20261029-ai27-27-2c77ed65cec2@gmail.com> (raw)
led_pwm_mc_probe() leaks the multi-led node reference on successful
probe and if the final PWM update fails. LED registration borrows
the node, so it must remain valid until the LED is unregistered.
Register a managed put action before LED registration. Reverse devres
order then unregisters the LED before releasing the node on unbind
or probe failure. Remove the explicit error-path put to avoid
releasing the reference twice.
Fixes: 9fa2762110dd ("leds: Add PWM multicolor driver")
Assisted-by: LLM
Signed-off-by: Yige Jiang <yigejiang86@gmail.com>
---
Based on linux-next next-20261016 (2efb7a11f1aa).
Compile-tested: arm64, GCC 14.2.0, W=1, CONFIG_OF_DYNAMIC=y.
COMPILE_TEST=y.
The object was built from this exact base with the patch applied.
No full kernel or module-link, hardware or runtime test was performed.
drivers/leds/rgb/leds-pwm-multicolor.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/drivers/leds/rgb/leds-pwm-multicolor.c b/drivers/leds/rgb/leds-pwm-multicolor.c
index 6365459ec27f17187804153cde6cb1805eca33e9..0ccf6839bc65f282f7c821e9fe7a50f431cc0d71 100644
--- a/drivers/leds/rgb/leds-pwm-multicolor.c
+++ b/drivers/leds/rgb/leds-pwm-multicolor.c
@@ -106,6 +106,11 @@ release_fwnode:
return ret;
}
+static void led_pwm_mc_put_node(void *data)
+{
+ fwnode_handle_put(data);
+}
+
static int led_pwm_mc_probe(struct platform_device *pdev)
{
struct fwnode_handle *mcnode;
@@ -121,6 +126,10 @@ static int led_pwm_mc_probe(struct platform_device *pdev)
return dev_err_probe(&pdev->dev, -ENODEV,
"expected multi-led node\n");
+ ret = devm_add_action_or_reset(&pdev->dev, led_pwm_mc_put_node, mcnode);
+ if (ret)
+ return ret;
+
/* count the nodes inside the multi-led node */
count = fwnode_get_child_node_count(mcnode);
@@ -174,7 +183,6 @@ static int led_pwm_mc_probe(struct platform_device *pdev)
return 0;
release_mcnode:
- fwnode_handle_put(mcnode);
return ret;
}
base-commit: 2efb7a11f1aa4d2dc285fe2680cca22cb9f72f64
reply other threads:[~2026-10-30 1:39 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=rc-review-20261029-ai27-27-2c77ed65cec2@gmail.com \
--to=yigejiang86@gmail.com \
--cc=griffin@kroah.com \
--cc=lee@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--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®