From: sashiko-bot@kernel.org
To: "Svyatoslav Ryhel" <clamor95@gmail.com>
Cc: linux-leds@vger.kernel.org, devicetree@vger.kernel.org,
mfd@lists.linux.dev, dri-devel@lists.freedesktop.org,
robh@kernel.org, conor+dt@kernel.org, lee@kernel.org
Subject: Re: [PATCH v5 3/4] mfd: aat2870: Convert to use OF bindings
Date: Tue, 27 Oct 2026 11:46:09 +0000 [thread overview]
Message-ID: <sashiko-outbox-186471@kernel.org> (raw)
In-Reply-To: <20261027113230.47538-4-clamor95@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] backlight: aat2870_bl: uninitialized max_current in aat2870_bl_probe()
--
commit 303056dfc011ffb951cd71d913b86ff6e8d6b044
Author: Svyatoslav Ryhel <clamor95@gmail.com>
mfd: aat2870: Convert to use OF bindings
This commit converts the AAT2870 MFD core, regulator, and backlight drivers to
use Device Tree bindings and modern GPIO and regulator frameworks, removing
legacy platform data support.
> diff --git a/drivers/video/backlight/aat2870_bl.c b/drivers/video/backlight/aat2870_bl.c
> index e85f2b4d81068..8e889e35621bb 100644
> --- a/drivers/video/backlight/aat2870_bl.c
> +++ b/drivers/video/backlight/aat2870_bl.c
[ ... ]
> @@ -84,24 +92,12 @@ static const struct backlight_ops aat2870_bl_ops = {
>
> static int aat2870_bl_probe(struct platform_device *pdev)
> {
> - struct aat2870_bl_platform_data *pdata = dev_get_platdata(&pdev->dev);
> struct aat2870_bl_driver_data *aat2870_bl;
> struct backlight_device *bd;
> struct backlight_properties props;
> + u32 max_current;
> int ret = 0;
[ ... ]
> @@ -128,19 +124,19 @@ static int aat2870_bl_probe(struct platform_device *pdev)
>
> aat2870_bl->bd = bd;
>
> - if (pdata->channels > 0)
> - aat2870_bl->channels = pdata->channels;
> - else
> - aat2870_bl->channels = AAT2870_BL_CH_ALL;
> + aat2870_bl->channels = AAT2870_BL_CH_ALL;
> + device_property_read_u8(&pdev->dev, "skyworks,channels", &aat2870_bl->channels);
> +
> + device_property_read_u32(&pdev->dev, "led-max-microamp", &max_current);
> + max_current = clamp(max_current, AAT2870_CURRENT_MIN, AAT2870_CURRENT_MAX);
> + max_current /= AAT2870_CURRENT_STEP;
>
> /*
> * The maximum number of brightness steps is determined by the max current.
> - * The aat2870_current enum maps directly to the allowed brightness steps.
> + * The max_current value calculated above maps to the allowed brightness
> + * steps with +1 offset since max_current 0 is still 450uA.
> */
> - if (pdata->max_current > 0)
> - bd->props.max_brightness = pdata->max_current;
> - else
> - bd->props.max_brightness = AAT2870_CURRENT_27_9;
> + bd->props.max_brightness = max_current + 1;
[Severity: High]
In aat2870_bl_probe(), max_current is declared on the stack without an
initial value. Unlike aat2870_bl->channels, which is initialized to
AAT2870_BL_CH_ALL before device_property_read_u8(), max_current is passed
directly to device_property_read_u32() without a default value or a return
value check.
When the optional led-max-microamp property is absent from the Device Tree
node, device_property_read_u32() returns -EINVAL without modifying
max_current.
Does this cause clamp() to read an uninitialized stack variable, resulting in
an arbitrary bd->props.max_brightness value that aat2870_bl_update_status()
then programs into the AAT2870_BLM register? Should max_current be
initialized to AAT2870_CURRENT_MAX prior to calling
device_property_read_u32()?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261027113230.47538-1-clamor95@gmail.com?part=3
next prev parent reply other threads:[~2026-10-27 11:46 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-27 11:32 [PATCH v5 0/4] mfd: aat2870: Convert to use OF bindings Svyatoslav Ryhel
2026-10-27 11:32 ` [PATCH v5 1/4] dt-bindings: leds: Document Skyworks AAT2870 Svyatoslav Ryhel
2026-10-27 11:32 ` [PATCH v5 2/4] backlight: aat2870: Derive brightness steps from max current Svyatoslav Ryhel
2026-10-27 11:32 ` [PATCH v5 3/4] mfd: aat2870: Convert to use OF bindings Svyatoslav Ryhel
2026-10-27 11:46 ` sashiko-bot [this message]
2026-10-27 11:32 ` [PATCH v5 4/4] mfd: aat2870: Add support for VIN and IN-LDO power supplies Svyatoslav Ryhel
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-186471@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=clamor95@gmail.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=lee@kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=mfd@lists.linux.dev \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox