From: sashiko-bot@kernel.org
To: "Stefan Wahren" <wahrenst@gmx.net>
Cc: robh@kernel.org, conor+dt@kernel.org, linux-leds@vger.kernel.org,
lee@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH V2 2/2] leds: rgb: leds-group-multicolor: Implement default-intensity
Date: Sun, 02 Aug 2026 12:11:45 +0000 [thread overview]
Message-ID: <20260802121146.483D11F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260802115727.50411-3-wahrenst@gmx.net>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues:
- [Medium] Device Tree Binding & Implementation Mismatch for `default-intensity`
Pre-existing issues:
- [High] 32-bit unsigned integer overflow and potential division by zero in brightness scaling calculation
--
--- Patch [2]: [PATCH V2 2/2] leds: rgb: leds-group-multicolor: Implement default-intensity ---
commit 3299ece4693e9a064de7eb3b6ca548536d4ca2ef
Author: Stefan Wahren <wahrenst@gmx.net>
leds: rgb: leds-group-multicolor: Implement default-intensity
Currently it is not possible to specify the initial color of a LED multicolor
group during boot. This commit implements the default-intensity property
similar to the leds-pwm-multicolor driver, falling back to the maximum
intensity if the property is missing.
> diff --git a/drivers/leds/rgb/leds-group-multicolor.c b/drivers/leds/rgb/leds-group-multicolor.c
> index a707d51c6a4bd..f0e6c2a25a070 100644
> --- a/drivers/leds/rgb/leds-group-multicolor.c
> +++ b/drivers/leds/rgb/leds-group-multicolor.c
> @@ -108,8 +108,14 @@ static int leds_gmc_probe(struct platform_device *pdev)
>
> subled[i].color_index = led_cdev->color;
>
> - /* Configure the LED intensity to its maximum */
> - subled[i].intensity = max_brightness;
> + ret = fwnode_property_read_u32(led_cdev->dev->fwnode, "default-intensity",
> + &subled[i].intensity);
[Severity: Medium]
Will this parse the default-intensity property from the correct node?
Based on the device tree binding documentation for leds-group-multicolor, the
default-intensity property is expected to be located in the parent multicolor
group node.
However, in leds_gmc_probe(), the driver attempts to read it from the
monochromatic sub-LED fwnode instead:
ret = fwnode_property_read_u32(led_cdev->dev->fwnode, "default-intensity",
&subled[i].intensity);
Does this code ignore valid configurations where the property is placed in the
parent node according to the schema?
> +
> + /* In case default-intensity is missing, fallback to maximum */
> + if (ret)
> + subled[i].intensity = max_brightness;
> + else if (subled[i].intensity > max_brightness)
> + subled[i].intensity = max_brightness;
> }
>
> /* Initialise the multicolor's LED class device */
[Severity: High]
This is a pre-existing issue, but is there a potential integer overflow and
division by zero when scaling brightness in leds_gmc_set()?
When leds_gmc_set() calculates the brightness for the monochromatic sub-LEDs,
it uses 32-bit unsigned arithmetic:
drivers/leds/rgb/leds-group-multicolor.c:leds_gmc_set() {
...
mono_brightness = DIV_ROUND_CLOSEST(brightness * intensity * mono_max_brightness,
group_max_brightness * group_max_brightness);
...
}
If the underlying LEDs have high max_brightness values configured (for example,
65535 for a PWM period), the numerator can wrap around, resulting in a
calculated brightness of 0.
Furthermore, if group_max_brightness happens to be exactly 65536, the
denominator overflows to exactly 0, which would lead to a division by zero
panic during brightness adjustment.
Could this arithmetic be adjusted to prevent overflows with high brightness
values?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260802115727.50411-1-wahrenst@gmx.net?part=2
prev parent reply other threads:[~2026-08-02 12:11 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-02 11:57 [PATCH V2 0/2] leds: rgb: leds-group-multicolor: Implement default-intensity Stefan Wahren
2026-08-02 11:57 ` [PATCH V2 1/2] dt-bindings: leds-group-multicolor: Enable default-intensity Stefan Wahren
2026-08-02 12:09 ` sashiko-bot
2026-08-02 11:57 ` [PATCH V2 2/2] leds: rgb: leds-group-multicolor: Implement default-intensity Stefan Wahren
2026-08-02 12:11 ` 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=20260802121146.483D11F000E9@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=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=wahrenst@gmx.net \
/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