From: sashiko-bot@kernel.org
To: "Svyatoslav Ryhel" <clamor95@gmail.com>
Cc: linux-leds@vger.kernel.org, lee@kernel.org
Subject: Re: [PATCH v2 2/2] leds: lm3533: Support getting LED sources from DT
Date: Fri, 04 Dec 2026 06:30:13 +0000 [thread overview]
Message-ID: <sashiko-outbox-249229@kernel.org> (raw)
In-Reply-To: <20261204061642.40608-3-clamor95@gmail.com>
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [High] leds: lm3533: lm3533_led_setup() reads led-sources from parent
MFD device
- [High] leds: lm3533: use-after-free of led->cb.dev in
lm3533_disable_ctrlbank()
- [Low] leds: lm3533: lm3533_led_setup() formats unsigned u32 leds[i]
with %d
--
commit ec80b3ed37ca724fa304228edf3fde088c418ee7
Author: Svyatoslav Ryhel <clamor95@gmail.com>
leds: lm3533: Support getting LED sources from DT
This commit adds support for reading the led-sources device tree property
in lm3533_led_setup() to configure the control bank to LVLED output
mapping in LM3533_REG_OUTPUT_CONF1 and LM3533_REG_OUTPUT_CONF2.
> diff --git a/drivers/leds/leds-lm3533.c b/drivers/leds/leds-lm3533.c
> index 25b2a9225af9e..90fd9a331e2b2 100644
> --- a/drivers/leds/leds-lm3533.c
> +++ b/drivers/leds/leds-lm3533.c
[ ... ]
> @@ -622,8 +632,60 @@ static const struct attribute_group *lm3533_led_attribute_groups[] = {
>
> static int lm3533_led_setup(struct lm3533_led *led)
> {
> + struct device *dev = led->cb.dev;
> + u32 leds[LM3533_LVLED_COUNT] = { };
> + u32 output_cfg_shift = 0;
> + u32 output_cfg_val = 0;
> + u32 output_cfg_mask = 0;
> + int num_leds;
> int ret;
>
> + /*
> + * If led-sources property is not set then either this Control Bank uses
> + * its default LVLED or is not linked to any LVLED at all.
> + */
> + num_leds = device_property_count_u32(dev, "led-sources");
[Severity: High]
Does this query led-sources on the parent MFD device instead of the LED
child platform device?
lm3533_led_probe() sets led->cb.dev to lm3533->dev (the parent I2C device)
before calling lm3533_led_setup(), whereas led-sources belongs on the child
ti,lm3533-leds node attached to &pdev->dev.
On valid device trees, device_property_count_u32() fails, num_leds is
clamped to 0, and LM3533_REG_OUTPUT_CONF1 and LM3533_REG_OUTPUT_CONF2 are
never updated; dev_err_probe() also logs against the parent I2C device.
Passing &pdev->dev into lm3533_led_setup() would fix this.
[ ... ]
> + for (int i = 0; i < num_leds; i++) {
> + if (leds[i] > LM3533_LVLED_INDEX_MAX)
> + return dev_err_probe(dev, -EINVAL,
> + "LVLED index exceeds maximum %d: %d\n",
> + LM3533_LVLED_INDEX_MAX, leds[i]);
[Severity: Low]
Should the second format specifier be %u instead of %d since leds[i] is a
u32? Values at or above 0x80000000 would otherwise be printed as negative
numbers.
[Severity: High]
Can lm3533_disable_ctrlbank() cause a use-after-free of led->cb.dev on
unbind or MFD removal?
In commit "leds: lm3533: Clean up probe and use managed helpers",
lm3533_led_probe() registers lm3533_disable_ctrlbank before
devm_led_classdev_register() and then aliases led->cb.dev to led->cdev.dev:
drivers/leds/leds-lm3533.c:lm3533_led_probe() {
...
ret = devm_add_action_or_reset(dev, lm3533_disable_ctrlbank, &led->cb);
if (ret)
return ret;
ret = devm_led_classdev_register(dev, &led->cdev);
if (ret)
return dev_err_probe(dev, ret, "Failed to register LED %d\n", pdev->id);
led->cb.dev = led->cdev.dev;
...
}
Because devres runs in LIFO order, devm_led_classdev_release() calls
led_classdev_unregister() -> device_unregister(led_cdev->dev) and frees
led->cdev.dev first. lm3533_disable_ctrlbank() -> lm3533_ctrlbank_disable()
then dereferences the freed cb->dev in dev_dbg() and dev_err().
Keeping led->cb.dev pointing to &pdev->dev, or registering
lm3533_disable_ctrlbank after devm_led_classdev_register(), avoids this.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261204061642.40608-1-clamor95@gmail.com?part=2
prev parent reply other threads:[~2026-12-04 6:30 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 6:16 [PATCH v2 0/2] leds: lm3533: cleanups and support getting LED sources from DT Svyatoslav Ryhel
2026-12-04 6:16 ` [PATCH v2 1/2] leds: lm3533: Clean up probe and use managed helpers Svyatoslav Ryhel
2026-12-04 6:26 ` sashiko-bot
2026-12-04 6:16 ` [PATCH v2 2/2] leds: lm3533: Support getting LED sources from DT Svyatoslav Ryhel
2026-12-04 6:30 ` 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-249229@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=clamor95@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 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.