From: sashiko-bot@kernel.org
To: "Rillian Grant" <rillian.grant@gmail.com>
Cc: linux-leds@vger.kernel.org, lee@kernel.org,
devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v2 2/4] leds: flash: Add support for the TI LM3643 dual LED flash driver
Date: Mon, 28 Sep 2026 09:54:47 +0000 [thread overview]
Message-ID: <20260928095447.6D6B81F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260928094302.86966-3-rillian.grant@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] leds: TOCTOU race in max_brightness clamping after registration
--
commit 0af4a3a129a9adf0eccf2c17265d6d72e8d4acac
Author: Rillian Grant <rillian.grant@gmail.com>
leds: flash: Add support for the TI LM3643 dual LED flash driver
This commit adds support for the TI LM3643 dual LED flash driver. The chip
features two high-side current sources sharing a synchronous boost converter,
supporting programmable torch and flash modes with fault reporting.
> diff --git a/drivers/leds/flash/leds-lm3643.c b/drivers/leds/flash/leds-lm3643.c
> new file mode 100644
> index 0000000000000..bbe9358c9caaf
> --- /dev/null
> +++ b/drivers/leds/flash/leds-lm3643.c
[ ... ]
> +static int lm3643_register_led(struct device *dev, struct lm3643 *chip,
> + struct fwnode_handle *fwnode)
> +{
[ ... ]
> + ret = devm_led_classdev_flash_register_ext(dev, flash_cdev, &init_data);
> + if (ret)
> + return ret;
> +
> + if (led_cdev->max_brightness > torch_max_brightness) {
> + dev_warn(dev, "max-brightness %u not supported (using %u)\n",
> + led_cdev->max_brightness,
> + torch_max_brightness);
> + led_cdev->max_brightness = torch_max_brightness;
> + }
[Severity: Medium]
Is there a TOCTOU race condition here? By clamping
led_cdev->max_brightness after calling
devm_led_classdev_flash_register_ext(), isn't there a window where the
device is exposed to userspace with the unclamped value?
Once registered, sysfs attributes are active and a KOBJ_ADD uevent is sent.
Could a fast userspace process read the unclamped max_brightness and
write an over-limit brightness value before the driver clamps it,
potentially driving the LED beyond its configured led-max-microamp
thermal limit?
This could happen if a device tree provides a max-brightness property
higher than the led-max-microamp limit. The LED core's
led_classdev_register_ext() overwrites led_cdev->max_brightness with
this value and creates the sysfs interfaces before this subsequent clamping
step runs.
> +
> + return lm3643_register_v4l2(dev, led, fwnode);
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260928094302.86966-1-rillian.grant@gmail.com?part=2
next prev parent reply other threads:[~2026-09-28 9:54 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-28 9:42 [PATCH v2 0/4] leds: flash: LM3643 dual LED flash driver Rillian Grant
2026-09-28 9:42 ` [PATCH v2 1/4] dt-bindings: leds: Document TI " Rillian Grant
2026-09-28 9:49 ` sashiko-bot
2026-10-01 6:34 ` Krzysztof Kozlowski
2026-09-28 9:42 ` [PATCH v2 2/4] leds: flash: Add support for the " Rillian Grant
2026-09-28 9:54 ` sashiko-bot [this message]
2026-09-28 9:42 ` [PATCH v2 3/4] leds: flash: lm3643: Describe the LED of ACPI boards without LED nodes Rillian Grant
2026-09-28 9:50 ` sashiko-bot
2026-09-28 10:08 ` Rillian Grant
2026-09-28 9:42 ` [PATCH v2 4/4] leds: flash: lm3643: Describe the LED on the Lenovo ThinkPad X9-15 Gen 1 Rillian Grant
2026-09-28 9:49 ` sashiko-bot
2026-09-29 9:29 ` [PATCH v2 0/4] leds: flash: LM3643 dual LED flash driver Ruslan Koreev
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=20260928095447.6D6B81F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=lee@kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=rillian.grant@gmail.com \
--cc=robh@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.