Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Svyatoslav Ryhel" <clamor95@gmail.com>
Cc: conor+dt@kernel.org, robh@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v3 07/11] mfd: lm3533: Set DMA mask
Date: Mon, 01 Jun 2026 15:28:32 +0000	[thread overview]
Message-ID: <20260601152832.9CD6B1F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260601151831.76350-8-clamor95@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Out-of-bounds write in `lm3533_device_init` when processing child nodes with multiple compatible strings.
--

commit d3029bf43673fb0132c36c4614c542e46d64f393
Author: Svyatoslav Ryhel <clamor95@gmail.com>

mfd: lm3533: Set DMA mask

This commit sets the coherent_dma_mask and dma_mask to 0 during the i2c
probe. This resolves a warning about missing DMA mask assignments, as
neither the core nor child devices use DMA.

> diff --git a/drivers/mfd/lm3533-core.c b/drivers/mfd/lm3533-core.c
> index 4dca5641b7744..b597d338d6f78 100644
> --- a/drivers/mfd/lm3533-core.c
> +++ b/drivers/mfd/lm3533-core.c

[ ... ]

> @@ -491,6 +491,10 @@ static int lm3533_i2c_probe(struct i2c_client *i2c)
>  				   LM3533_BOOST_FREQ_MAX);
>  	lm3533->boost_freq = lm3533->boost_freq / (500 * KILO) - 1;
>  
> +	/* LM3533 and child devices do not use DMA */
> +	i2c->dev.coherent_dma_mask = 0;
> +	i2c->dev.dma_mask = &i2c->dev.coherent_dma_mask;
> +
>  	return lm3533_device_init(lm3533);

[Severity: High]
This is a pre-existing issue, but can the child node iteration in
lm3533_device_init() overflow the lm3533_devices array?

The lm3533_devices array is allocated based on nchilds. Inside the
iteration loop, independent if statements check the compatible strings:

drivers/mfd/lm3533-core.c:lm3533_device_init() {
    ...
    if (fwnode_device_is_compatible(child, "ti,lm3533-als")) {
        lm3533_devices[count].name = "lm3533-als";
        ...
        count++;
    }

    if (fwnode_device_is_compatible(child, "ti,lm3533-backlight")) {
        ...
        lm3533_devices[count].name = "lm3533-backlight";
        ...
        count++;
    }
    ...
}

Since the bounds check if (count >= nchilds) is only performed once at
the beginning of the loop, a single child node containing multiple matching
compatible strings (e.g., "ti,lm3533-als" and "ti,lm3533-backlight") would
increment count multiple times per iteration.

Could this bypass the bounds check and cause an out-of-bounds write?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260601151831.76350-1-clamor95@gmail.com?part=7

  reply	other threads:[~2026-06-01 15:28 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-01 15:18 [PATCH v3 00/11] mfd: lm3533: convert to OF bindings, improve support Svyatoslav Ryhel
2026-06-01 15:18 ` [PATCH v3 01/11] dt-bindings: leds: Document TI LM3533 LED controller Svyatoslav Ryhel
2026-06-01 15:18 ` [PATCH v3 02/11] mfd: lm3533: Remove driver specific regmap wrappers Svyatoslav Ryhel
2026-06-01 15:18 ` [PATCH v3 03/11] iio: light: lm3533-als: Remove redundant pdata helpers Svyatoslav Ryhel
2026-06-01 15:18 ` [PATCH v3 04/11] mfd: lm3533-core: " Svyatoslav Ryhel
2026-06-01 15:18 ` [PATCH v3 05/11] mfd: lm3533: Convert to use OF bindings Svyatoslav Ryhel
2026-06-01 15:35   ` sashiko-bot
2026-06-01 15:18 ` [PATCH v3 06/11] mfd: lm3533: Add support for VIN power supply Svyatoslav Ryhel
2026-06-01 15:18 ` [PATCH v3 07/11] mfd: lm3533: Set DMA mask Svyatoslav Ryhel
2026-06-01 15:28   ` sashiko-bot [this message]
2026-06-01 15:18 ` [PATCH v3 08/11] video: backlight: lm3533_bl: Improve linear sysfs logic Svyatoslav Ryhel
2026-06-01 15:18 ` [PATCH v3 09/11] video: backlight: lm3533_bl: Set initial mapping mode from DT Svyatoslav Ryhel
2026-06-01 15:18 ` [PATCH v3 10/11] video: backlight: lm3533_bl: Implement backlight_scale property Svyatoslav Ryhel
2026-06-01 15:37   ` sashiko-bot
2026-06-01 15:18 ` [PATCH v3 11/11] video: leds: backlight: lm3533: Support getting LED sources from DT Svyatoslav Ryhel
2026-06-01 15:37   ` sashiko-bot

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=20260601152832.9CD6B1F00893@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=clamor95@gmail.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --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