From: sashiko-bot@kernel.org
To: "Linus Walleij" <linusw@kernel.org>
Cc: devicetree@vger.kernel.org, vkoul@kernel.org, robh@kernel.org,
conor+dt@kernel.org, dmaengine@vger.kernel.org,
Frank.Li@kernel.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 10/11] regulator: db8500: Add power domain regulators
Date: Thu, 18 Jun 2026 05:23:24 +0000 [thread overview]
Message-ID: <20260618052325.4F5A11F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260618-ux500-power-domains-v7-1-v1-10-eb5e50b1a588@kernel.org>
Thank you for your contribution! Sashiko AI review found 5 potential issue(s) to consider:
- [High] The `db8500_regulator_disable` callback incorrectly treats a return value of 1 from `pm_runtime_put_sync_suspend` as an error, causing early abort and state desynchronization.
- [High] Mismatched Genpd APIs (`of_genpd_add_device` paired with `dev_pm_domain_detach`) lead to a silent detach failure and Use-After-Free list corruption.
- [High] Embedding a `struct device` in a devres-managed structure (`devm_kzalloc`) with an empty release function causes a lifecycle violation and Use-After-Free.
- [High] The virtual device is never fully registered with `device_add()`, leading to a memory leak of PM QoS constraints.
- [High] The driver saves an OF node pointer to the persistent device structure without incrementing its reference count, risking a dangling pointer.
--
commit abd72295748300bd01e4a7216b2321ff24b1a38f
Author: Linus Walleij <linusw@kernel.org>
regulator: db8500: Add power domain regulators
Add a DB8500 regulator driver for the VAPE and VSMPS2 compatibility nodes,
backing the regulator enable state with corresponding power domains.
> diff --git a/drivers/regulator/db8500-regulator.c b/drivers/regulator/db8500-regulator.c
> new file mode 100644
> index 0000000000000..c5a9a1baaf8ea
> --- /dev/null
> +++ b/drivers/regulator/db8500-regulator.c
[ ... ]
> +static int db8500_regulator_disable(struct regulator_dev *rdev)
> +{
> + struct db8500_regulator_info *info = rdev_get_drvdata(rdev);
> + int ret;
> +
> + ret = pm_runtime_put_sync_suspend(&info->pd_dev);
> + if (ret)
> + return ret;
[Severity: High]
Does this propagate a success status as an error?
According to the PM subsystem rules, pm_runtime_put_sync_suspend() returns 1
when the device is already in the RPM_SUSPENDED state. Since this checks
if (ret) and returns it, won't the regulator core treat this as a failure,
aborting the disable operation and leaving the regulator's use_count and
enable_count out of sync?
[ ... ]
> +static void db8500_regulator_release(struct device *dev)
> +{
> +}
[Severity: High]
Does this empty release function circumvent kobject lifecycle tracking?
The struct device is embedded in devres memory allocated via devm_kzalloc().
Since put_device() does not guarantee synchronous memory reclamation, will
devres forcibly free the memory when the driver unbinds, creating a
use-after-free for any subsystem still holding a reference to pd_dev?
> +
> +static void db8500_regulator_cleanup(void *data)
> +{
> + struct db8500_regulator_info *info = data;
> +
> + pm_runtime_disable(&info->pd_dev);
> + dev_pm_domain_detach(&info->pd_dev, true);
[Severity: High]
Will this detach silently fail?
The device is attached using of_genpd_add_device(), which adds it to
genpd->dev_list but does not populate the dev->pm_domain->detach callback.
Since dev_pm_domain_detach() checks for that callback, won't it be a no-op,
leaving the device in the genpd active lists when freed and causing a
use-after-free?
Should this use pm_genpd_remove_device() instead?
> + put_device(&info->pd_dev);
> +}
[ ... ]
> +static int db8500_regulator_register(struct platform_device *pdev,
> + struct device_node *np)
> +{
[ ... ]
> + info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL);
> + if (!info)
> + return -ENOMEM;
> +
> + device_initialize(&info->pd_dev);
> + info->pd_dev.parent = &pdev->dev;
> + info->pd_dev.of_node = np;
[Severity: High]
Could this leave a dangling pointer in info->pd_dev.of_node?
The np pointer is provided by for_each_available_child_of_node() in
db8500_regulator_probe(), which automatically drops the reference on the
node when advancing the loop.
Since of_node_get() isn't used here to increment the reference count, will
the reference be dropped when the loop concludes?
> + info->pd_dev.release = db8500_regulator_release;
> + ret = dev_set_name(&info->pd_dev, "%s-pd", match->name);
> + if (ret)
> + goto put_device;
> +
> + ret = of_parse_phandle_with_args(np, "power-domains", cells, 0, &pd_args);
> + if (ret)
> + goto put_device;
> +
> + ret = of_genpd_add_device(&pd_args, &info->pd_dev);
[Severity: High]
Does this leak PM QoS constraints?
The device is initialized with device_initialize() but never fully registered
with device_add().
Since of_genpd_add_device() automatically registers a resume latency QoS
notifier that dynamically allocates PM QoS constraint structures, and those
are normally freed by device_del(), will these structures leak upon cleanup
because device_del() is never called?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260618-ux500-power-domains-v7-1-v1-0-eb5e50b1a588@kernel.org?part=10
next prev parent reply other threads:[~2026-06-18 5:23 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-18 5:00 [PATCH 00/11] pmdomain: st: ux500: Implement ux500 power domains Linus Walleij
2026-06-18 5:00 ` [PATCH 01/11] dt-bindings: power: Convert Ux500 PM domains to schema Linus Walleij
2026-06-18 5:07 ` sashiko-bot
2026-06-18 5:00 ` [PATCH 02/11] dt-bindings: Add the actual power domains on U8500 Linus Walleij
2026-06-18 5:00 ` [PATCH 03/11] pmdomain: st: ux500: Implement more power domains Linus Walleij
2026-06-18 5:10 ` sashiko-bot
2026-06-18 5:00 ` [PATCH 04/11] ARM: dts: ux500: Rename power domains node Linus Walleij
2026-06-18 5:00 ` [PATCH 05/11] ARM: dts: ux500: Add power domains Linus Walleij
2026-06-18 5:14 ` sashiko-bot
2026-06-18 5:00 ` [PATCH 06/11] pmdomain: st: ux500: Control DB8500 EPODs Linus Walleij
2026-06-18 5:14 ` sashiko-bot
2026-06-18 5:00 ` [PATCH 07/11] drm/mcde: Use power domain for display power Linus Walleij
2026-06-18 5:11 ` sashiko-bot
2026-06-18 5:00 ` [PATCH 08/11] dmaengine: ste_dma40: Use power domain for LCLA SRAM Linus Walleij
2026-06-18 5:15 ` sashiko-bot
2026-06-18 5:00 ` [PATCH 09/11] regulator: db8500-prcmu: Remove EPOD regulators Linus Walleij
2026-06-18 5:15 ` sashiko-bot
2026-06-18 5:00 ` [PATCH 10/11] regulator: db8500: Add power domain regulators Linus Walleij
2026-06-18 5:23 ` sashiko-bot [this message]
2026-06-18 5:00 ` [PATCH 11/11] ARM: dts: ux500: Remove DB8500 EPOD regulators Linus Walleij
2026-06-18 7:20 ` 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=20260618052325.4F5A11F00A3A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Frank.Li@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dmaengine@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=linusw@kernel.org \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=vkoul@kernel.org \
/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.