From: sashiko-bot@kernel.org
To: "Luca Leonardo Scorcia" <l.scorcia@gmail.com>
Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org,
mfd@lists.linux.dev, linux-gpio@vger.kernel.org, robh@kernel.org,
conor+dt@kernel.org, dmitry.torokhov@gmail.com, lee@kernel.org
Subject: Re: [PATCH RESEND v10 8/9] regulator: Add MediaTek MT6392 regulator
Date: Tue, 20 Oct 2026 17:48:58 +0000 [thread overview]
Message-ID: <sashiko-outbox-179446@kernel.org> (raw)
In-Reply-To: <20261020173556.632798-9-l.scorcia@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] regulator: mt6392: OF node reference leak in mt6392_regulator_probe()
--
commit 04b22037bb949a80f26c6f5651752d61ee106b28
Author: Fabien Parent <parent.f@gmail.com>
regulator: Add MediaTek MT6392 regulator
This commit adds a regulator driver for the MediaTek MT6392 PMIC.
> diff --git a/drivers/regulator/mt6392-regulator.c b/drivers/regulator/mt6392-regulator.c
> new file mode 100644
> index 0000000000000..3db52268363e0
> --- /dev/null
> +++ b/drivers/regulator/mt6392-regulator.c
> @@ -0,0 +1,764 @@
[ ... ]
> +static int mt6392_regulator_probe(struct platform_device *pdev)
> +{
> + struct mt6397_chip *mt6392 = dev_get_drvdata(pdev->dev.parent);
> + struct regulator_config config = {};
> + struct regulator_dev *rdev;
> + int i;
> +
> + device_set_of_node_from_dev(&pdev->dev, pdev->dev.parent);
> +
> + // Initialize the bucks' vsel_reg and vsel_mask according to current HW state
> + if (mt6392_set_buck_vsel_reg(pdev))
> + return -EIO;
> +
> + config.dev = mt6392->dev;
> + config.regmap = mt6392->regmap;
[Severity: Medium]
Does calling device_set_of_node_from_dev() here leak a reference on
pdev->dev.parent->of_node when the platform device is released?
In drivers/mfd/mt6397-core.c, the mt6392-regulator cell is defined without an
of_compatible string, so mfd_add_device() allocates the child device via
platform_device_alloc() with pdev->dev.of_node and pdev->dev.fwnode set to
NULL.
Calling device_set_of_node_from_dev() in mt6392_regulator_probe() increments
the reference count on pdev->dev.parent->of_node and assigns it to
pdev->dev.of_node, without setting pdev->dev.fwnode:
drivers/base/core.c:device_set_of_node_from_dev() {
of_node_put(dev->of_node);
dev->of_node = of_node_get(dev2->of_node);
dev_set_of_node_reused(dev);
}
When the platform device is later torn down, platform_device_release() only
puts pa->pdev.dev.fwnode:
drivers/base/platform.c:platform_device_release() {
...
if (!is_software_node(dev_fwnode(dev)))
fwnode_handle_put(pa->pdev.dev.fwnode);
...
}
Since pdev->dev.fwnode remains NULL, fwnode_handle_put() is a no-op and the
reference on pdev->dev.of_node is never dropped.
Also, since config.dev is already set to mt6392->dev (the parent device),
which the regulator core uses for DT node and supply lookups, could the
device_set_of_node_from_dev() call simply be dropped (or replaced with
platform_device_set_of_node_from_dev() if needed)?
[ ... ]
> + return 0;
> +}
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261020173556.632798-1-l.scorcia@gmail.com?part=8
next prev parent reply other threads:[~2026-10-20 17:49 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-20 17:33 [PATCH RESEND v10 0/9] Add support for MT6392 PMIC Luca Leonardo Scorcia
2026-10-20 17:33 ` [PATCH RESEND v10 1/9] dt-bindings: mfd: mt6397: Add " Luca Leonardo Scorcia
2026-10-21 2:14 ` Rob Herring (Arm)
2026-10-21 2:32 ` Rob Herring
2026-10-20 17:33 ` [PATCH RESEND v10 2/9] dt-bindings: input: mtk-pmic-keys: Add MT6392 PMIC keys Luca Leonardo Scorcia
2026-10-20 17:33 ` [PATCH RESEND v10 3/9] regulator: dt-bindings: Add MediaTek MT6392 PMIC Luca Leonardo Scorcia
2026-10-20 17:33 ` [PATCH RESEND v10 4/9] mfd: mt6397: Use MFD_CELL_* to describe sub-devices Luca Leonardo Scorcia
2026-10-20 17:33 ` [PATCH RESEND v10 5/9] mfd: mt6397: Add support for MT6392 PMIC Luca Leonardo Scorcia
2026-10-20 17:33 ` [PATCH RESEND v10 6/9] input: keyboard: mtk-pmic-keys: Add MT6392 support Luca Leonardo Scorcia
2026-10-20 17:33 ` [PATCH RESEND v10 7/9] pinctrl: mediatek: mt6397: Add MediaTek MT6392 Luca Leonardo Scorcia
2026-10-20 17:33 ` [PATCH RESEND v10 8/9] regulator: Add MediaTek MT6392 regulator Luca Leonardo Scorcia
2026-10-20 17:48 ` sashiko-bot [this message]
2026-10-20 17:33 ` [PATCH RESEND v10 9/9] arm64: dts: mediatek: Add MediaTek MT6392 PMIC dtsi Luca Leonardo Scorcia
2026-10-20 17:47 ` 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=sashiko-outbox-179446@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-gpio@vger.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.