All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Uwe Kleine-König (The Capable Hub)" <u.kleine-koenig@baylibre.com>
Cc: Frank.Li@kernel.org, mfd@lists.linux.dev,
	wsa+renesas@sang-engineering.com, imx@lists.linux.dev,
	lee@kernel.org
Subject: Re: [PATCH v3 13/23] mfd: Use named initializers for arrays of i2c_device_id
Date: Thu, 09 Jul 2026 17:14:58 +0000	[thread overview]
Message-ID: <20260709171458.CE72A1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <244319440376f5f34b213c5df3ae3996dec5e732.1783615311.git.u.kleine-koenig@baylibre.com>

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

Pre-existing issues:
- [High] Missing `.remove` callback and cleanup for `mfd_add_devices()` leads to Use-After-Free on unbind.
- [High] Dynamic amendment of a global non-const `mfd_cell` array.
- [High] Passing complex pointers and platform data via the `.data` field of the `of_device_id` match table.
--

--- Patch [13]: [PATCH v3 13/23] mfd: Use named initializers for arrays of i2c_device_id ---
commit 17d93c846df3c3e646099533f0b8856a806eee55
Author: Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@baylibre.com>

mfd: Use named initializers for arrays of i2c_device_id

This commit updates various MFD drivers to use named initializers for
i2c_device_id arrays. This improves code readability and ensures robustness
against future changes to the i2c_device_id struct definition.

> diff --git a/drivers/mfd/ti-lmu.c b/drivers/mfd/ti-lmu.c
> --- a/drivers/mfd/ti-lmu.c
> +++ b/drivers/mfd/ti-lmu.c
> @@ -206,11 +206,11 @@ static const struct of_device_id ti_lmu_of_match[] = {
>  MODULE_DEVICE_TABLE(of, ti_lmu_of_match);
>  
>  static const struct i2c_device_id ti_lmu_ids[] = {

[Severity: High]
This is a pre-existing issue, but looking at ti_lmu_of_match just above
this hunk in drivers/mfd/ti-lmu.c, it appears to pass pointers to platform
data structs (like &lm3631_data) via the data field of the of_device_id
match table.

The MFD subsystem guidelines prohibit passing complex pointers through match
tables due to memory safety hazards and initialization ordering races. Could
this be refactored to use integer IDs or enums instead?

> -	{ "lm3631", LM3631 },
> -	{ "lm3632", LM3632 },
> -	{ "lm3633", LM3633 },
> -	{ "lm3695", LM3695 },
> -	{ "lm36274", LM36274 },
> +	{ .name = "lm3631", .driver_data = LM3631 },
> +	{ .name = "lm3632", .driver_data = LM3632 },
> +	{ .name = "lm3633", .driver_data = LM3633 },
> +	{ .name = "lm3695", .driver_data = LM3695 },
> +	{ .name = "lm36274", .driver_data = LM36274 },
>  	{ }
>  };

[ ... ]

> diff --git a/drivers/mfd/tps65090.c b/drivers/mfd/tps65090.c
> --- a/drivers/mfd/tps65090.c
> +++ b/drivers/mfd/tps65090.c
> @@ -225,7 +225,7 @@ static int tps65090_i2c_probe(struct i2c_client *client)
>  
>  
>  static const struct i2c_device_id tps65090_id_table[] = {

[Severity: High]
This isn't a bug introduced by this patch, but looking at
tps65090_i2c_probe() in drivers/mfd/tps65090.c, it modifies the global
tps65090s array dynamically before getting to this table:

tps65090s[CHARGER].num_resources = 0;

Since this modifies a shared global mfd_cell array, can this cause a data
race or initialization corruption if multiple instances of the driver probe
concurrently or sequentially with different IRQ configurations?

> -	{ "tps65090" },
> +	{ .name = "tps65090" },
>  	{ }
>  };

[ ... ]

> diff --git a/drivers/mfd/tps65218.c b/drivers/mfd/tps65218.c
> --- a/drivers/mfd/tps65218.c
> +++ b/drivers/mfd/tps65218.c
> @@ -336,8 +336,8 @@ static int tps65218_probe(struct i2c_client *client)
>  }
>  
>  static const struct i2c_device_id tps65218_id_table[] = {

[Severity: High]
This is a pre-existing issue, but earlier in tps65218_probe() in
drivers/mfd/tps65218.c, mfd_add_devices() is called manually without using
the devm_mfd_add_devices variant.

Since there is no remove callback for this driver to call
mfd_remove_devices(), does this leak the child devices and cause a
use-after-free on the devm-allocated parent data when the driver is unbound?

> -	{ "tps65218", TPS65218 },
> -	{ },
> +	{ .name = "tps65218", .driver_data = TPS65218 },
> +	{ }
>  };
>  MODULE_DEVICE_TABLE(i2c, tps65218_id_table);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1783615311.git.u.kleine-koenig@baylibre.com?part=13

  reply	other threads:[~2026-07-09 17:14 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-09 16:58 [PATCH v3 00/23] mfd: Use named initializers for arrays of *_device_data Uwe Kleine-König (The Capable Hub)
2026-07-09 16:58 ` Uwe Kleine-König (The Capable Hub)
2026-07-09 16:58 ` [PATCH v3 01/23] mfd: bcm2835-pm: Remove member of struct bcm2835_pm that is only used locally Uwe Kleine-König (The Capable Hub)
2026-07-09 16:58 ` [PATCH v3 02/23] mfd: bcm2835-pm: Drop unused header Uwe Kleine-König (The Capable Hub)
2026-07-09 16:58 ` [PATCH v3 03/23] mfd: kempld: Simplify device abstraction Uwe Kleine-König (The Capable Hub)
2026-07-09 16:58 ` [PATCH v3 04/23] mfd: lp87565: Explicitly set driver data for the generic dt compatible Uwe Kleine-König (The Capable Hub)
2026-07-09 16:58 ` [PATCH v3 05/23] mfd: mt6360: Drop irrelevant __maybe_unused Uwe Kleine-König (The Capable Hub)
2026-07-09 16:58 ` [PATCH v3 06/23] mfd: rt4831: " Uwe Kleine-König (The Capable Hub)
2026-07-09 16:58 ` [PATCH v3 07/23] mfd: loongson-se: Drop unused assignment of acpi_device_id driver data Uwe Kleine-König (The Capable Hub)
2026-07-09 16:58 ` [PATCH v3 08/23] mfd: Drop unused assignment of i2c_device_id " Uwe Kleine-König (The Capable Hub)
2026-07-09 16:58 ` [PATCH v3 09/23] mfd: Drop unused assignment of platform_device_id " Uwe Kleine-König (The Capable Hub)
2026-07-09 16:58 ` [PATCH v3 10/23] mfd: Drop unused assignment of spi_device_id " Uwe Kleine-König (The Capable Hub)
2026-07-09 16:58 ` [PATCH v3 11/23] mfd: Use named initializers for acpi_device_id arrays Uwe Kleine-König (The Capable Hub)
2026-07-09 16:58 ` [PATCH v3 12/23] mfd: intel-m10-bmc-pmci: Use named initializers for dfl_device_id array Uwe Kleine-König (The Capable Hub)
2026-07-09 16:58 ` [PATCH v3 13/23] mfd: Use named initializers for arrays of i2c_device_id Uwe Kleine-König (The Capable Hub)
2026-07-09 17:14   ` sashiko-bot [this message]
2026-07-09 16:58 ` [PATCH v3 14/23] mfd: twl6030: Use named initializers for of_device_id Uwe Kleine-König (The Capable Hub)
2026-07-09 16:58 ` [PATCH v3 15/23] mfd: Use PCI_DEVICE* macros to initialize pci_device_id arrays Uwe Kleine-König (The Capable Hub)
2026-07-09 16:58 ` [PATCH v3 16/23] mfd: Use named initializers for platform_device_id array Uwe Kleine-König (The Capable Hub)
2026-07-09 16:58 ` [PATCH v3 17/23] mfd: Use named initializers for arrays of spi_device_id Uwe Kleine-König (The Capable Hub)
2026-07-09 16:58 ` [PATCH v3 18/23] mfd: Unify style of acpi_device_id arrays Uwe Kleine-König (The Capable Hub)
2026-07-09 16:58 ` [PATCH v3 19/23] mfd: Unify style of dmi_system_id arrays Uwe Kleine-König (The Capable Hub)
2026-07-09 16:58 ` [PATCH v3 20/23] mfd: Unify style of i2c_device_id arrays Uwe Kleine-König (The Capable Hub)
2026-07-09 16:58 ` [PATCH v3 21/23] mfd: Unify style of of_device_id arrays Uwe Kleine-König (The Capable Hub)
2026-07-09 16:58   ` Uwe Kleine-König (The Capable Hub)
2026-07-09 17:19   ` sashiko-bot
2026-07-09 17:19     ` sashiko-bot
2026-07-10 10:21   ` Geert Uytterhoeven
2026-07-10 10:21     ` Geert Uytterhoeven
2026-07-10 13:00   ` Mathieu Dubois-Briand
2026-07-10 13:00     ` Mathieu Dubois-Briand
2026-07-10 13:15     ` Krzysztof Kozlowski
2026-07-10 13:15       ` Krzysztof Kozlowski
2026-07-10 16:54       ` Charles Keepax
2026-07-10 16:54         ` Charles Keepax
2026-07-09 16:58 ` [PATCH v3 22/23] mfd: Unify style of pci_device_id arrays Uwe Kleine-König (The Capable Hub)
2026-07-09 16:58 ` [PATCH v3 23/23] mfd: Unify style of spi_device_id arrays Uwe Kleine-König (The Capable Hub)
2026-07-10 19:45 ` [PATCH v3 00/23] mfd: Use named initializers for arrays of *_device_data Linus Walleij
2026-07-10 19:45   ` Linus Walleij

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=20260709171458.CE72A1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=imx@lists.linux.dev \
    --cc=lee@kernel.org \
    --cc=mfd@lists.linux.dev \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=u.kleine-koenig@baylibre.com \
    --cc=wsa+renesas@sang-engineering.com \
    /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.