* [PATCH] leds: lp50xx: Read default intensity from devicetree
@ 2026-11-09 12:58 Tobias Johansson
2026-11-09 13:09 ` sashiko-bot
2026-11-19 9:52 ` Lee Jones
0 siblings, 2 replies; 5+ messages in thread
From: Tobias Johansson @ 2026-11-09 12:58 UTC (permalink / raw)
To: Lee Jones, Pavel Machek
Cc: linux-leds, linux-kernel, kernel, Tobias Johansson
Read the default-intensity property for each LP50xx multicolor
component so that the configured color intensities are available
when brightness is applied. This allows LEDs to use the intended
RGB values without first writing multi_intensity from userspace.
Leave the intensity at zero when the property is absent.
Signed-off-by: Tobias Johansson <tobias.johansson@axis.com>
---
drivers/leds/leds-lp50xx.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/leds/leds-lp50xx.c b/drivers/leds/leds-lp50xx.c
index 20bfb315bda1..019a3e3cad05 100644
--- a/drivers/leds/leds-lp50xx.c
+++ b/drivers/leds/leds-lp50xx.c
@@ -522,6 +522,8 @@ static int lp50xx_probe_dt(struct lp50xx *priv)
dev_err(priv->dev, "reg %i out of range\n", multi_index);
return -EINVAL;
}
+ fwnode_property_read_u32(led_node, "default-intensity",
+ &mc_led_info[multi_index].intensity);
mc_led_info[multi_index].color_index = color_id;
mc_led_info[multi_index].max_intensity = 255;
---
base-commit: 05b4738b0078f7d6f154f68068a11c8a0635e9df
change-id: 20260914-b4-leds-lp50xx-default-intensity-345d4cc702b4
Best regards,
--
Tobias Johansson <tobias.johansson@axis.com>
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] leds: lp50xx: Read default intensity from devicetree
2026-11-09 12:58 [PATCH] leds: lp50xx: Read default intensity from devicetree Tobias Johansson
@ 2026-11-09 13:09 ` sashiko-bot
2026-11-19 9:52 ` Lee Jones
1 sibling, 0 replies; 5+ messages in thread
From: sashiko-bot @ 2026-11-09 13:09 UTC (permalink / raw)
To: Tobias Johansson; +Cc: linux-leds, lee
Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [Critical] leds: lp50xx: heap out-of-bounds access in
lp50xx_brightness_set() [1]
--
commit 79b801d6a9355ec03170294fd226b03df2a33733
Author: Tobias Johansson <tobias.johansson@axis.com>
leds: lp50xx: Read default intensity from devicetree
This commit reads the default-intensity property from device tree for each
LP50xx multicolor sub-LED component during probe.
> diff --git a/drivers/leds/leds-lp50xx.c b/drivers/leds/leds-lp50xx.c
> index 20bfb315bda1d..019a3e3cad057 100644
> --- a/drivers/leds/leds-lp50xx.c
> +++ b/drivers/leds/leds-lp50xx.c
> @@ -522,6 +522,8 @@ static int lp50xx_probe_dt(struct lp50xx *priv)
> dev_err(priv->dev, "reg %i out of range\n", multi_index);
> return -EINVAL;
> }
> + fwnode_property_read_u32(led_node, "default-intensity",
> + &mc_led_info[multi_index].intensity);
>
> mc_led_info[multi_index].color_index = color_id;
> mc_led_info[multi_index].max_intensity = 255;
[Severity: Critical]
This problem wasn't introduced by this patch, but can num_colors exceed
LP50XX_LEDS_PER_MODULE and cause an out-of-bounds access on mc_led_info[]
[1]?
mc_led_info is allocated with LP50XX_LEDS_PER_MODULE (3) elements, and
lp50xx_probe_dt() checks that multi_index < LP50XX_LEDS_PER_MODULE, but
num_colors is incremented unconditionally for every child node. If a
device tree defines more than three sub-LED nodes that reuse valid reg
indices, led->mc_cdev.num_colors will exceed 3, causing
multi_intensity_store() and lp50xx_brightness_set() to read and write past
the end of subled_info[].
[1] https://sashiko.dev/#/bug/linux-a0c116ab-2f34-4f53-a007-d7a42f28677b
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261109-b4-leds-lp50xx-default-intensity-v1-1-0a04a3533df6@axis.com?part=1
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] leds: lp50xx: Read default intensity from devicetree
2026-11-09 12:58 [PATCH] leds: lp50xx: Read default intensity from devicetree Tobias Johansson
2026-11-09 13:09 ` sashiko-bot
@ 2026-11-19 9:52 ` Lee Jones
2026-11-23 12:36 ` Tobias Johansson
1 sibling, 1 reply; 5+ messages in thread
From: Lee Jones @ 2026-11-19 9:52 UTC (permalink / raw)
To: Tobias Johansson; +Cc: Pavel Machek, linux-leds, linux-kernel, kernel
On Mon, 09 Nov 2026, Tobias Johansson wrote:
Please review, explain or fix the Sashiko review(s).
> Read the default-intensity property for each LP50xx multicolor
> component so that the configured color intensities are available
> when brightness is applied. This allows LEDs to use the intended
> RGB values without first writing multi_intensity from userspace.
>
> Leave the intensity at zero when the property is absent.
>
> Signed-off-by: Tobias Johansson <tobias.johansson@axis.com>
> ---
> drivers/leds/leds-lp50xx.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/leds/leds-lp50xx.c b/drivers/leds/leds-lp50xx.c
> index 20bfb315bda1..019a3e3cad05 100644
> --- a/drivers/leds/leds-lp50xx.c
> +++ b/drivers/leds/leds-lp50xx.c
> @@ -522,6 +522,8 @@ static int lp50xx_probe_dt(struct lp50xx *priv)
> dev_err(priv->dev, "reg %i out of range\n", multi_index);
> return -EINVAL;
> }
> + fwnode_property_read_u32(led_node, "default-intensity",
> + &mc_led_info[multi_index].intensity);
(multi_index >= LP50XX_LEDS_PER_MODULE) only tests for values too large.
What happens if `multi_index` is < 0? OOB?
> mc_led_info[multi_index].color_index = color_id;
> mc_led_info[multi_index].max_intensity = 255;
>
> ---
> base-commit: 05b4738b0078f7d6f154f68068a11c8a0635e9df
> change-id: 20260914-b4-leds-lp50xx-default-intensity-345d4cc702b4
>
> Best regards,
> --
> Tobias Johansson <tobias.johansson@axis.com>
>
--
Lee Jones
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] leds: lp50xx: Read default intensity from devicetree
2026-11-19 9:52 ` Lee Jones
@ 2026-11-23 12:36 ` Tobias Johansson
2026-12-02 12:09 ` Lee Jones
0 siblings, 1 reply; 5+ messages in thread
From: Tobias Johansson @ 2026-11-23 12:36 UTC (permalink / raw)
To: lee@kernel.org, Tobias Johansson
Cc: pavel@kernel.org, linux-leds@vger.kernel.org,
linux-kernel@vger.kernel.org, Kernel
On Thu, 2026-11-19 at 09:52 +0000, Lee Jones wrote:
> On Mon, 09 Nov 2026, Tobias Johansson wrote:
>
> Please review, explain or fix the Sashiko review(s).
>
The issue Sashiko flagged is a real pre-existing bug: num_colors is
incremented for every child node, so a devicetree with more than three
sub-LED nodes reusing valid reg indices makes num_colors exceed the
subled_info allocation. I can fix this by rejecting LED nodes with more
than LP50XX_LEDS_PER_MODULE children.
> > + fwnode_property_read_u32(led_node,
> > "default-intensity",
> > +
> > &mc_led_info[multi_index].intensity);
>
> (multi_index >= LP50XX_LEDS_PER_MODULE) only tests for values too
> large.
>
> What happens if `multi_index` is < 0? OOB?
>
Yes, good catch. multi_index is read with fwnode_property_read_u32()
into a signed int, so values with the high bit set become negative and
bypass the upper-bound check, causing an OOB write. I can change
multi_index to u32 so the existing check covers it.
Since both issues are pre-existing and caused by malformed devicetrees,
I can send up a new patch series to fix these two issues hopefully
sometime this week.
>
Thanks,
Tobias
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] leds: lp50xx: Read default intensity from devicetree
2026-11-23 12:36 ` Tobias Johansson
@ 2026-12-02 12:09 ` Lee Jones
0 siblings, 0 replies; 5+ messages in thread
From: Lee Jones @ 2026-12-02 12:09 UTC (permalink / raw)
To: Tobias Johansson
Cc: pavel@kernel.org, linux-leds@vger.kernel.org,
linux-kernel@vger.kernel.org, Kernel
On Mon, 23 Nov 2026, Tobias Johansson wrote:
> On Thu, 2026-11-19 at 09:52 +0000, Lee Jones wrote:
> > On Mon, 09 Nov 2026, Tobias Johansson wrote:
> >
> > Please review, explain or fix the Sashiko review(s).
> >
>
> The issue Sashiko flagged is a real pre-existing bug: num_colors is
> incremented for every child node, so a devicetree with more than three
> sub-LED nodes reusing valid reg indices makes num_colors exceed the
> subled_info allocation. I can fix this by rejecting LED nodes with more
> than LP50XX_LEDS_PER_MODULE children.
>
> > > + fwnode_property_read_u32(led_node,
> > > "default-intensity",
> > > +
> > > &mc_led_info[multi_index].intensity);
> >
> > (multi_index >= LP50XX_LEDS_PER_MODULE) only tests for values too
> > large.
> >
> > What happens if `multi_index` is < 0? OOB?
> >
>
> Yes, good catch. multi_index is read with fwnode_property_read_u32()
> into a signed int, so values with the high bit set become negative and
> bypass the upper-bound check, causing an OOB write. I can change
> multi_index to u32 so the existing check covers it.
>
> Since both issues are pre-existing and caused by malformed devicetrees,
> I can send up a new patch series to fix these two issues hopefully
> sometime this week.
It would be ideal if you could include this patch as part of the set.
--
Lee Jones
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-12-02 12:09 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-09 12:58 [PATCH] leds: lp50xx: Read default intensity from devicetree Tobias Johansson
2026-11-09 13:09 ` sashiko-bot
2026-11-19 9:52 ` Lee Jones
2026-11-23 12:36 ` Tobias Johansson
2026-12-02 12:09 ` Lee Jones
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox