All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Luca Leonardo Scorcia" <l.scorcia@gmail.com>
Cc: conor+dt@kernel.org, robh@kernel.org, lee@kernel.org,
	dmitry.torokhov@gmail.com, linux-input@vger.kernel.org,
	devicetree@vger.kernel.org, mfd@lists.linux.dev
Subject: Re: [PATCH v10 5/9] mfd: mt6397: Add support for MT6392 PMIC
Date: Wed, 02 Sep 2026 20:24:59 +0000	[thread overview]
Message-ID: <20260902202459.D11551F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260902193351.185771-6-l.scorcia@gmail.com>

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

New issues:
- [Low] Driver-specific header files were added to the global include/linux/mfd/ directory, violating MFD subsystem guidelines.

Pre-existing issues:
- [High] Incomplete resource cleanup in probe error path and missing driver `.remove` callback lead to Use-After-Free and resource leaks.
--

commit cf917ffc4ed0ebfc40bb77132283778e31d7ae09
Author: Fabien Parent <parent.f@gmail.com>

mfd: mt6397: Add support for MT6392 PMIC

Align the MT6397 PMIC driver to other MFD drivers by passing only an
identifier through mt6397_of_match[*].data and add support for the MT6392
PMIC and its regulator, RTC, keys and pinctrl devices.

> diff --git a/drivers/mfd/mt6397-core.c b/drivers/mfd/mt6397-core.c
> index 3e08179002fad..f284d3885ae18 100644
> --- a/drivers/mfd/mt6397-core.c
> +++ b/drivers/mfd/mt6397-core.c
[ ... ]
> @@ -282,6 +317,7 @@ static int mt6397_probe(struct platform_device *pdev)
>  	unsigned int id = 0;
>  	struct mt6397_chip *pmic;
>  	const struct chip_data *pmic_core;
> +	int chip_variant;
>  
>  	pmic = devm_kzalloc(&pdev->dev, sizeof(*pmic), GFP_KERNEL);
>  	if (!pmic)

[Severity: High]
This isn't a bug introduced by this patch, but doesn't the lack of a .remove
callback and incomplete probe error handling leak resources and cause a
use-after-free?

If devm_mfd_add_devices() fails during mt6397_probe(), or if the driver is
unbound via sysfs, devres automatically frees the mt6397_chip structure.
However, mt6397_irq_init() registers a PM notifier:

drivers/mfd/mt6397-irq.c:mt6397_irq_init() {
    ...
    register_pm_notifier(&chip->pm_nb);
    return 0;
}

This is never unregistered because there is no explicit cleanup on the probe
error path, and no .remove callback is defined in mt6397_driver:

drivers/mfd/mt6397-core.c:
static struct platform_driver mt6397_driver = {
    .probe = mt6397_probe,
    .driver = {
        .name = "mt6397",
        .of_match_table = mt6397_of_match,
    },
};

When the system subsequently suspends, the PM core invokes the dangling
notifier_call, causing a UAF.

Additionally, the error path destroys the irq domain while the managed IRQ
thread is still active:

drivers/mfd/mt6397-core.c:mt6397_probe() {
    ...
    if (ret) {
        irq_domain_remove(pmic->irq_domain);
        dev_err(&pdev->dev, "failed to add child devices: %d\n", ret);
    }
    ...
}

Does this create a UAF window if an interrupt fires before devres cleans up
the devm-managed IRQ handler mt6397_irq_thread?

> diff --git a/include/linux/mfd/mt6392/core.h b/include/linux/mfd/mt6392/core.h
> new file mode 100644
> index 0000000000000..8777b3abf9292
> --- /dev/null
> +++ b/include/linux/mfd/mt6392/core.h
> @@ -0,0 +1,43 @@
> +/* SPDX-License-Identifier: GPL-2.0 */

[Severity: Low]
Does placing this driver-specific header file in the global include/linux/mfd/
directory violate MFD subsystem layering guidelines?

The MFD subsystem guidelines state: "Do not include driver-specific header
files in the global include/linux/mfd/ directory if they are only used by the
parent and its immediate children. Keep them local to drivers/mfd/."

> diff --git a/include/linux/mfd/mt6392/registers.h b/include/linux/mfd/mt6392/registers.h
> new file mode 100644
> index 0000000000000..68fe9af448f5d
> --- /dev/null
> +++ b/include/linux/mfd/mt6392/registers.h
> @@ -0,0 +1,488 @@
> +/* SPDX-License-Identifier: GPL-2.0 */

[Severity: Low]
Is it intentional to place these driver-specific registers in the global
include directory rather than keeping them local to drivers/mfd/?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260902193351.185771-1-l.scorcia@gmail.com?part=5

  reply	other threads:[~2026-09-02 20:25 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-02 19:25 [PATCH v10 0/9] Add support for MT6392 PMIC Luca Leonardo Scorcia
2026-09-02 19:25 ` [PATCH v10 1/9] dt-bindings: mfd: mt6397: Add " Luca Leonardo Scorcia
2026-09-02 19:41   ` sashiko-bot
2026-09-03  8:24   ` Krzysztof Kozlowski
2026-09-08  7:06   ` AngeloGioacchino Del Regno
2026-09-02 19:25 ` [PATCH v10 2/9] dt-bindings: input: mtk-pmic-keys: Add MT6392 PMIC keys Luca Leonardo Scorcia
2026-09-02 19:50   ` sashiko-bot
2026-09-02 19:25 ` [PATCH v10 3/9] regulator: dt-bindings: Add MediaTek MT6392 PMIC Luca Leonardo Scorcia
2026-09-02 20:00   ` sashiko-bot
2026-09-02 19:25 ` [PATCH v10 4/9] mfd: mt6397: Use MFD_CELL_* to describe sub-devices Luca Leonardo Scorcia
2026-09-02 20:10   ` sashiko-bot
2026-09-02 19:25 ` [PATCH v10 5/9] mfd: mt6397: Add support for MT6392 PMIC Luca Leonardo Scorcia
2026-09-02 20:24   ` sashiko-bot [this message]
2026-09-02 19:25 ` [PATCH v10 6/9] input: keyboard: mtk-pmic-keys: Add MT6392 support Luca Leonardo Scorcia
2026-09-02 20:37   ` sashiko-bot
2026-09-02 19:25 ` [PATCH v10 7/9] pinctrl: mediatek: mt6397: Add MediaTek MT6392 Luca Leonardo Scorcia
2026-09-02 20:50   ` sashiko-bot
2026-09-02 19:25 ` [PATCH v10 8/9] regulator: Add MediaTek MT6392 regulator Luca Leonardo Scorcia
2026-09-02 20:58   ` sashiko-bot
2026-09-02 19:25 ` [PATCH v10 9/9] arm64: dts: mediatek: Add MediaTek MT6392 PMIC dtsi Luca Leonardo Scorcia
2026-09-02 21:05   ` sashiko-bot
2026-09-08  7:06   ` AngeloGioacchino Del Regno

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=20260902202459.D11551F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=l.scorcia@gmail.com \
    --cc=lee@kernel.org \
    --cc=linux-input@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 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.