* [PATCH] leds: pwm-multicolor: manage the multi-led node reference
@ 2026-10-30 1:39 Yige Jiang
2026-10-30 1:46 ` sashiko-bot
0 siblings, 1 reply; 2+ messages in thread
From: Yige Jiang @ 2026-10-30 1:39 UTC (permalink / raw)
To: linux-leds; +Cc: Lee Jones, Pavel Machek, Griffin Kroah-Hartman, linux-kernel
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] leds: pwm-multicolor: manage the multi-led node reference
2026-10-30 1:39 [PATCH] leds: pwm-multicolor: manage the multi-led node reference Yige Jiang
@ 2026-10-30 1:46 ` sashiko-bot
0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-10-30 1:46 UTC (permalink / raw)
To: Yige Jiang, linux-leds; +Cc: lee
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Low] leds: pwm-multicolor: lowercase commit subject description
- [Low] leds: pwm-multicolor: unused release_mcnode label in led_pwm_mc_probe()
--
commit 67921ff7042ba5bbedd0da0b44a4a770d241be02
Author: Yige Jiang <yigejiang86@gmail.com>
leds: pwm-multicolor: manage the multi-led node reference
This commit registers a devm action in led_pwm_mc_probe() to release the
multi-led fwnode reference upon driver unbind or probe failure, and removes
the manual fwnode_handle_put() call on the error path.
> leds: pwm-multicolor: manage the multi-led node reference
>
> 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>
[Severity: Low]
Should the commit subject description after the subsystem and driver prefix
be capitalized to follow the LED subsystem convention:
leds: pwm-multicolor: Manage the multi-led node reference
> diff --git a/drivers/leds/rgb/leds-pwm-multicolor.c b/drivers/leds/rgb/leds-pwm-multicolor.c
> index 6365459ec27f1..0ccf6839bc65f 100644
> --- a/drivers/leds/rgb/leds-pwm-multicolor.c
> +++ b/drivers/leds/rgb/leds-pwm-multicolor.c
[ ... ]
> @@ -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;
> }
[Severity: Low]
In led_pwm_mc_probe() in drivers/leds/rgb/leds-pwm-multicolor.c, now that
fwnode_handle_put(mcnode) is registered via devm_add_action_or_reset() and
removed from the release_mcnode label, the release_mcnode label only executes
return ret.
Could the release_mcnode label and the goto release_mcnode jumps on the
subsequent error paths in led_pwm_mc_probe() be removed in favor of returning
directly?
--
Sashiko AI review · https://sashiko.dev/#/patchset/rc-review-20261029-ai27-27-2c77ed65cec2@gmail.com?part=1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-10-30 1:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-30 1:39 [PATCH] leds: pwm-multicolor: manage the multi-led node reference Yige Jiang
2026-10-30 1:46 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox