From: sashiko-bot@kernel.org
To: "Geert Uytterhoeven" <geert+renesas@glider.be>
Cc: wsa+renesas@sang-engineering.com, conor+dt@kernel.org,
robh@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v2 4/6] pmdomain: renesas: Add R-Car X5H MDLC driver
Date: Wed, 08 Jul 2026 10:36:12 +0000 [thread overview]
Message-ID: <20260708103613.4A28F1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <23f979b0903ca11513ac339ab8b6dd40435603c5.1783505142.git.geert+renesas@glider.be>
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [High] Hardcoded index `0` in `of_parse_phandle_with_args()` breaks consumer devices attached to multiple power domains.
- [High] Use-After-Free of `priv` due to premature release of `r8a78000_mdlc_lock`.
- [High] AB-BA deadlock (lockdep splat) between `r8a78000_mdlc_lock` and the global `gpd_list_lock`.
- [Medium] Missing dummy clocks despite claims in the commit message.
--
--- Patch [4]: [PATCH v2 4/6] pmdomain: renesas: Add R-Car X5H MDLC driver ---
commit 1970ea51b8c9b00b6533ff3db2920ecb99d83f17
Author: Geert Uytterhoeven <geert+renesas@glider.be>
pmdomain: renesas: Add R-Car X5H MDLC driver
This adds a minimal Module Controller driver for the R-Car X5H (R8A78000)
SoC. It provides support for always-on power domains and dummy resets for
the serial console.
> For now this just supports the always-on power domains, and dummy clocks
> and resets for the serial console (which is enabled by the boot loader).
[Severity: Medium]
The commit message mentions adding dummy clocks, but looking at
r8a78000_mdlc_probe(), it appears only the genpd and reset controller
providers are registered. Will consumers defer indefinitely if they
attempt to use this driver as a clock provider?
> diff --git a/drivers/pmdomain/renesas/r8a78000-mdlc.c b/drivers/pmdomain/renesas/r8a78000-mdlc.c
> new file mode 100644
> index 0000000000000..ed367e921a334
> --- /dev/null
> +++ b/drivers/pmdomain/renesas/r8a78000-mdlc.c
[ ... ]
> +static int r8a78000_mdlc_attach_dev(struct generic_pm_domain *domain,
> + struct device *dev)
> +{
> + struct device_node *np = dev->of_node;
> + struct r8a78000_mdlc_priv *priv;
> + struct of_phandle_args pd_spec;
> + const struct mod_map *map;
> + unsigned int id;
> + int ret;
> +
> + ret = of_parse_phandle_with_args(np, "power-domains",
> + "#power-domain-cells", 0, &pd_spec);
[Severity: High]
Is it possible for a consumer device to have multiple power domains
configured in its device tree (e.g., <&sysc 1>, <&mdlc 2>)? If the
MDLC domain is not the first one in the property, won't this hardcoded
index of 0 fail to find the correct provider and cause the consumer
probe to fail with -ENODEV?
> + if (ret < 0)
> + return ret;
> +
> + if (pd_spec.args_count != 2) {
> + of_node_put(pd_spec.np);
> + return -EINVAL;
> + }
> +
> + scoped_guard(mutex, &r8a78000_mdlc_lock) {
> + hlist_for_each_entry(priv, &r8a78000_mdlc_list, link) {
> + if (priv->np == pd_spec.np)
> + break;
> + }
> + }
> +
> + if (!priv) {
> + dev_err(dev, "%s: MDLC %pOF not found\n", __func__, pd_spec.np);
> + of_node_put(pd_spec.np);
> + return -ENODEV;
> + }
> +
> + id = pd_spec.args[1];
> + of_node_put(pd_spec.np);
> +
> + map = mod_map_find(priv->mod_map, id);
[Severity: High]
Could priv be freed before we dereference it here? The lock protecting
the r8a78000_mdlc_list is released at the end of the scoped_guard() block
above.
If the provider's probe fails or the driver is unbound concurrently,
r8a78000_mdlc_unlink() will acquire the lock, remove priv from the list,
and free the memory. Since we access priv->mod_map here without holding
the lock, does this introduce a use-after-free window?
> + if (!map) {
> + dev_err(dev, "Unknown module 0x%x\n", id);
> + return -ENOENT;
> + }
[ ... ]
> +static int r8a78000_genpd_always_on_singleton(struct device *dev)
> +{
> + struct generic_pm_domain *genpd;
> + int ret;
> +
> + guard(mutex)(&r8a78000_mdlc_lock);
> +
> + if (r8a78000_genpd_always_on)
> + return 0;
> +
> + genpd = kzalloc_obj(*genpd);
> + if (!genpd)
> + return -ENOMEM;
> +
> + genpd->name = "always-on";
> + genpd->attach_dev = r8a78000_mdlc_attach_dev;
> +
> + ret = pm_genpd_init(genpd, &pm_domain_always_on_gov, false);
[Severity: High]
Will this sequence trigger a lockdep splat?
During this first probe, r8a78000_genpd_always_on_singleton() acquires
r8a78000_mdlc_lock and calls pm_genpd_init(), which acquires the global
gpd_list_lock. This establishes r8a78000_mdlc_lock -> gpd_list_lock.
Later, when a consumer device attaches, the PM domain core calls
r8a78000_mdlc_attach_dev() with gpd_list_lock held. That function then
acquires r8a78000_mdlc_lock via the scoped_guard() block, completing an
inverse lock order.
Should pm_genpd_init() be called outside the r8a78000_mdlc_lock critical
section to avoid this?
> + if (ret) {
> + kfree(genpd);
> + return dev_err_probe(dev, ret,
> + "Failed to create always-on domain\n");
> + }
> +
> + r8a78000_genpd_always_on = genpd;
> + return 0;
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1783505142.git.geert+renesas@glider.be?part=4
next prev parent reply other threads:[~2026-07-08 10:36 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-08 10:15 [PATCH v2 0/6] R-Car X5H CPG/MDLC support Geert Uytterhoeven
2026-07-08 10:15 ` [PATCH v2 1/6] dt-bindings: clock: Document Renesas R-Car X5H Clock Pulse Generator Geert Uytterhoeven
2026-07-08 16:32 ` Conor Dooley
2026-07-08 10:15 ` [PATCH v2 2/6] dt-bindings: power: Document Renesas R-Car X5H Module Controller Geert Uytterhoeven
2026-07-08 12:38 ` Marek Vasut
2026-07-08 16:32 ` Conor Dooley
2026-07-08 10:15 ` [PATCH v2 3/6] clk: renesas: Add R-Car X5H CPG driver Geert Uytterhoeven
2026-07-08 10:24 ` sashiko-bot
2026-07-08 12:40 ` Marek Vasut
2026-07-09 9:49 ` Geert Uytterhoeven
2026-07-12 22:22 ` Uwe Kleine-König
2026-07-13 8:19 ` Geert Uytterhoeven
2026-07-08 10:15 ` [PATCH v2 4/6] pmdomain: renesas: Add R-Car X5H MDLC driver Geert Uytterhoeven
2026-07-08 10:36 ` sashiko-bot [this message]
2026-07-08 12:47 ` Marek Vasut
2026-07-09 10:29 ` Geert Uytterhoeven
2026-07-14 12:04 ` Ulf Hansson
2026-07-15 9:10 ` Geert Uytterhoeven
2026-07-08 10:15 ` [PATCH v2 5/6] arm64: dts: renesas: r8a78000: Add CPG node Geert Uytterhoeven
2026-07-08 12:51 ` Marek Vasut
2026-07-08 10:15 ` [PATCH v2 6/6] arm64: dts: renesas: r8a78000: Add MDLC nodes Geert Uytterhoeven
2026-07-08 10:47 ` sashiko-bot
2026-07-09 10:15 ` Geert Uytterhoeven
2026-07-08 13:07 ` Marek Vasut
2026-07-09 10:24 ` Geert Uytterhoeven
2026-07-09 11:24 ` Marek Vasut
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=20260708103613.4A28F1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=geert+renesas@glider.be \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--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.