[PATCH 2/2] leds: lp50xx: Reject excessive component counts

From: Tobias Johansson

Date: Fri Nov 27 2026 - 08:45:00 EST


Each multicolor LED has storage for LP50XX_LEDS_PER_MODULE components,
but num_colors is incremented for every component child node. More than
three children with repeated valid reg values therefore produce a count
larger than the subled_info allocation.

The brightness and multicolor sysfs paths trust this count, resulting in
out-of-bounds reads and writes.

Reject firmware nodes containing more components than the allocation can
hold before parsing them. This bounds num_colors without changing the
handling of configurations with up to three components.

Reported-by: Sashiko <sashiko-bot@xxxxxxxxxx>
Link: https://lore.kernel.org/all/sashiko-outbox-204991@xxxxxxxxxx/
Fixes: 242b81170fb8 ("leds: lp50xx: Add the LP50XX family of the RGB LED driver")
Signed-off-by: Tobias Johansson <tobias.johansson@xxxxxxxx>
---
drivers/leds/leds-lp50xx.c | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/drivers/leds/leds-lp50xx.c b/drivers/leds/leds-lp50xx.c
index 4d4ad0db96af..4da78e6ad0aa 100644
--- a/drivers/leds/leds-lp50xx.c
+++ b/drivers/leds/leds-lp50xx.c
@@ -496,6 +496,11 @@ static int lp50xx_probe_dt(struct lp50xx *priv)
init_data.fwnode = child;
num_colors = 0;

+ if (fwnode_get_child_node_count(child) > LP50XX_LEDS_PER_MODULE) {
+ dev_err(priv->dev, "Too many sub-LEDs\n");
+ return -EINVAL;
+ }
+
/*
* There are only 3 LEDs per module otherwise they should be
* banked which also is presented as 3 LEDs.

--
2.43.0