[PATCH 1/2] leds: lp50xx: Use an unsigned component index

From: Tobias Johansson

Date: Fri Nov 27 2026 - 08:44:53 EST


The component reg property is read from a firmware node as a u32, but
multi_index is an int. A malformed firmware description with the high
bit set is interpreted as negative and passes the upper-bound check
against LP50XX_LEDS_PER_MODULE. Using such an index then writes out of
bounds at a negative offset from mc_led_info during probe.

Declare multi_index as u32 to match the property reader and ensure that
the existing bounds check rejects all values outside the allocation.
Update the diagnostic format specifier accordingly.

Reported-by: Lee Jones <lee@xxxxxxxxxx>
Link: https://lore.kernel.org/all/179442102947.44545.9103121805533352120@xxxxxxxxxx/
Fixes: 2e84a5e53742 ("leds: leds-lp50xx: Handle reg to get correct multi_index")
Signed-off-by: Tobias Johansson <tobias.johansson@xxxxxxxx>
---
drivers/leds/leds-lp50xx.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/leds/leds-lp50xx.c b/drivers/leds/leds-lp50xx.c
index 20bfb315bda1..4d4ad0db96af 100644
--- a/drivers/leds/leds-lp50xx.c
+++ b/drivers/leds/leds-lp50xx.c
@@ -506,7 +506,7 @@ static int lp50xx_probe_dt(struct lp50xx *priv)
return -ENOMEM;

fwnode_for_each_child_node(child, led_node) {
- int multi_index;
+ u32 multi_index;
ret = fwnode_property_read_u32(led_node, "color",
&color_id);
if (ret) {
@@ -519,7 +519,7 @@ static int lp50xx_probe_dt(struct lp50xx *priv)
dev_err(priv->dev, "reg must be set\n");
return -EINVAL;
} else if (multi_index >= LP50XX_LEDS_PER_MODULE) {
- dev_err(priv->dev, "reg %i out of range\n", multi_index);
+ dev_err(priv->dev, "reg %u out of range\n", multi_index);
return -EINVAL;
}


--
2.43.0