All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mert Seftali <mertsftl@gmail.com>
To: Lee Jones <lee@kernel.org>, Pavel Machek <pavel@kernel.org>
Cc: Steffen Trumtrar <s.trumtrar@pengutronix.de>,
	Dan Carpenter <error27@gmail.com>,
	linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org,
	Mert Seftali <mertsftl@gmail.com>,
	kernel test robot <lkp@intel.com>
Subject: [PATCH] leds: lp5860: Return an error for an out-of-range 'reg' property
Date: Fri, 12 Jun 2026 22:16:37 +0200	[thread overview]
Message-ID: <20260612201637.197608-1-mertsftl@gmail.com> (raw)

When fwnode_property_read_u32() succeeds but the channel number exceeds
LP5860_MAX_LED, ret is 0. The error path then passes 0 to dev_err_probe()
and returns 0, so an out-of-range "reg" value is silently treated as
success instead of being rejected.

Set ret to -EINVAL in that case so the invalid channel is reported and
propagated as an error.

Fixes: 3daf2c4ef82b ("leds: Add support for TI LP5860 LED driver chip")
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <error27@gmail.com>
Closes: https://lore.kernel.org/r/202605210624.3gcr3prk-lkp@intel.com/
Signed-off-by: Mert Seftali <mertsftl@gmail.com>
---
 drivers/leds/rgb/leds-lp5860-core.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/leds/rgb/leds-lp5860-core.c b/drivers/leds/rgb/leds-lp5860-core.c
index fd0e2f6e6e0f..9eeb01b3e56a 100644
--- a/drivers/leds/rgb/leds-lp5860-core.c
+++ b/drivers/leds/rgb/leds-lp5860-core.c
@@ -115,6 +115,8 @@ 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)
+				ret = -EINVAL;
 			dev_err_probe(led->chip->dev, ret,
 				      "%pfwP: 'reg' property is missing. Skipping.\n", led_node);
 			fwnode_handle_put(led_node);
-- 
2.54.0


             reply	other threads:[~2026-06-12 20:16 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-12 20:16 Mert Seftali [this message]
2026-06-18 11:55 ` [PATCH] leds: lp5860: Return an error for an out-of-range 'reg' property Lee Jones
2026-06-18 14:25   ` Mert Seftali

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=20260612201637.197608-1-mertsftl@gmail.com \
    --to=mertsftl@gmail.com \
    --cc=error27@gmail.com \
    --cc=lee@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=lkp@intel.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.