Linux LED subsystem development
 help / color / mirror / Atom feed
From: kr494167@gmail.com
To: lee@kernel.org, pavel@kernel.org
Cc: s.trumtrar@pengutronix.de, linux-leds@vger.kernel.org,
	linux-kernel@vger.kernel.org, surendra <kr494167@gmail.com>
Subject: [PATCH] leds: lp5860: reject out-of-range channel IDs
Date: Mon, 20 Jul 2026 16:00:17 +0530	[thread overview]
Message-ID: <20260720103017.88090-1-kr494167@gmail.com> (raw)

From: surendra <kr494167@gmail.com>

lp5860_iterate_subleds() detects a channel ID greater than the
hardware limit, but returns the successful result of
fwnode_property_read_u32(). The caller therefore treats the malformed
sub-LED description as valid and uses the invalid ID for register
addressing.

Return -EINVAL when the channel ID is out of range.

Fixes: f0a66563aa2d ("leds: Add support for TI LP5860 LED driver chip")
Signed-off-by: surendra <kr494167@gmail.com>
---
 drivers/leds/rgb/leds-lp5860-core.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/leds/rgb/leds-lp5860-core.c b/drivers/leds/rgb/leds-lp5860-core.c
index e21d5f2302be..75498311b080 100644
--- a/drivers/leds/rgb/leds-lp5860-core.c
+++ b/drivers/leds/rgb/leds-lp5860-core.c
@@ -114,12 +114,18 @@ static int lp5860_iterate_subleds(struct lp5860_led *led, struct led_init_data *
 		}
 
 		ret = fwnode_property_read_u32(led_node, "reg", &channel);
-		if (ret < 0 || channel > LP5860_MAX_LED) {
+		if (ret < 0) {
 			dev_err_probe(led->chip->dev, ret,
 				      "%pfwP: 'reg' property is missing. Skipping.\n", led_node);
 			fwnode_handle_put(led_node);
 			return ret;
 		}
+		if (channel > LP5860_MAX_LED) {
+			dev_err(led->chip->dev, "%pfwP: 'reg' property is out of range.\n",
+				led_node);
+			fwnode_handle_put(led_node);
+			return -EINVAL;
+		}
 
 		led->mc_cdev.subled_info[subled].color_index = color_index;
 		led->mc_cdev.subled_info[subled].channel = channel;
-- 
2.55.0


             reply	other threads:[~2026-07-20 10:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-20 10:30 kr494167 [this message]
2026-07-20 10:41 ` [PATCH] leds: lp5860: reject out-of-range channel IDs sashiko-bot

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=20260720103017.88090-1-kr494167@gmail.com \
    --to=kr494167@gmail.com \
    --cc=lee@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=pavel@kernel.org \
    --cc=s.trumtrar@pengutronix.de \
    /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