From: sashiko-bot@kernel.org
To: "Cong Nguyen" <congnt264@gmail.com>
Cc: linux-leds@vger.kernel.org, lee@kernel.org
Subject: Re: [PATCH] leds: rgb: ktd202x: allocate the LED array for the chip's LED count
Date: Tue, 24 Nov 2026 10:15:46 +0000 [thread overview]
Message-ID: <sashiko-outbox-230952@kernel.org> (raw)
In-Reply-To: <20261124095707.3852724-1-congnt264@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] leds: ktd202x: uninitialized chip->num_leds in ktd202x_probe()
--
commit acafdda47f9cb14e885911a263b15aa32abaff09
Author: Cong Nguyen <congnt264@gmail.com>
leds: rgb: ktd202x: allocate the LED array for the chip's LED count
This commit allocates chip->leds[] for the number of LEDs supported by the
chip rather than the number of firmware child nodes, and removes the later
assignment to chip->num_leds.
> diff --git a/drivers/leds/rgb/leds-ktd202x.c b/drivers/leds/rgb/leds-ktd202x.c
> index f1822281c3e61..56f6fa906b709 100644
> --- a/drivers/leds/rgb/leds-ktd202x.c
> +++ b/drivers/leds/rgb/leds-ktd202x.c
> @@ -533,6 +533,7 @@ static int ktd202x_probe(struct i2c_client *client)
> {
> struct device *dev = &client->dev;
> struct ktd202x *chip;
> + unsigned long num_leds;
> int count;
> int ret;
>
> @@ -540,7 +541,9 @@ static int ktd202x_probe(struct i2c_client *client)
> if (!count || count > KTD202X_MAX_LEDS)
> return dev_err_probe(dev, -EINVAL, "Incorrect number of leds (%d)", count);
>
> - chip = devm_kzalloc_flex(dev, *chip, leds, count);
> + num_leds = (unsigned long)i2c_get_match_data(client);
> +
> + chip = devm_kzalloc_flex(dev, *chip, leds, num_leds);
> if (!chip)
> return -ENOMEM;
>
> @@ -558,8 +561,6 @@ static int ktd202x_probe(struct i2c_client *client)
> if (ret)
> return ret;
>
> - chip->num_leds = (unsigned long)i2c_get_match_data(client);
[Severity: High]
Does removing this assignment leave chip->num_leds set to 0 on compilers
without working __builtin_counted_by_ref() support (GCC < 15.1 and
Clang < 22.1)?
When __builtin_counted_by_ref() is unavailable or
CONFIG_CC_HAS_BROKEN_COUNTED_BY_REF is set, __set_flex_counter() inside
devm_kzalloc_flex() is a no-op and does not populate chip->num_leds.
ktd202x_probe() -> ktd202x_probe_fw() then fails unconditionally with
-EINVAL:
drivers/leds/rgb/leds-ktd202x.c:ktd202x_probe_fw() {
count = device_get_child_node_count(dev);
if (!count || count > chip->num_leds)
return -EINVAL;
...
}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261124095707.3852724-1-congnt264@gmail.com?part=1
prev parent reply other threads:[~2026-11-24 10:15 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 9:57 [PATCH] leds: rgb: ktd202x: allocate the LED array for the chip's LED count Cong Nguyen
2026-11-24 10:15 ` sashiko-bot [this message]
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=sashiko-outbox-230952@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=congnt264@gmail.com \
--cc=lee@kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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