From: sashiko-bot@kernel.org
To: "Jiaxing Hu" <gahing@gahingwoo.com>
Cc: conor+dt@kernel.org, robh@kernel.org,
dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v12 10/14] pmdomain: rockchip: cycle optional power-domain resets on power-on
Date: Sat, 12 Sep 2026 07:04:27 +0000 [thread overview]
Message-ID: <20260912070428.1FC671F00898@smtp.kernel.org> (raw)
In-Reply-To: <20260912065053.1519165-11-gahing@gahingwoo.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Massive Use-After-Free of genpd structures if probe fails and pm_genpd_remove() fails during error cleanup.
--
commit 82ba89727b40b24aa0ac406b6e9c71489c988d78
Author: Jiaxing Hu <gahing@gahingwoo.com>
pmdomain: rockchip: cycle optional power-domain resets on power-on
Some Rockchip domains come out of power-on with their bus interface in an
undefined state. On the RK3576 NPU this shows up as a hang on the first
register access after the domain is switched on, and pulsing the domain's
resets at this point clears it.
> diff --git a/drivers/pmdomain/rockchip/pm-domains.c b/drivers/pmdomain/rockchip/pm-domains.c
> --- a/drivers/pmdomain/rockchip/pm-domains.c
> +++ b/drivers/pmdomain/rockchip/pm-domains.c
[ ... ]
> @@ -949,6 +975,7 @@ static void rockchip_pm_remove_one_domain(struct rockchip_pm_domain *pd)
>
> clk_bulk_unprepare(pd->num_clks, pd->clks);
> clk_bulk_put(pd->num_clks, pd->clks);
> + reset_control_put(pd->resets);
>
> /* protect the zeroing of pm->num_clks */
> mutex_lock(&pd->pmu->mutex);
[Severity: High]
This is a pre-existing issue, but does this error cleanup path leave a freed
structure in the global gpd_list if probe fails?
During error cleanup, rockchip_pm_domain_cleanup() iterates forward through
the domains array:
for (i = 0; i < pmu->genpd_data.num_domains; i++) {
genpd = pmu->genpd_data.domains[i];
if (genpd) {
pd = to_rockchip_pd(genpd);
rockchip_pm_remove_one_domain(pd);
}
}
Since parent domains typically appear before their children in the array, the
parent is visited first.
When rockchip_pm_remove_one_domain() attempts to remove the parent domain,
pm_genpd_remove() fails with -EBUSY because the child is still attached:
ret = pm_genpd_remove(&pd->genpd);
if (ret < 0)
dev_err(pd->pmu->dev, "failed to remove domain '%s' : %d...",
The domain is left in the global gpd_list and the function continues without
retrying.
Because rockchip_pm_add_one_domain() allocates the domain structure with
devm_kzalloc():
pd = devm_kzalloc(pmu->dev, sizeof(*pd), GFP_KERNEL);
When probe returns an error, such as -EPROBE_DEFER, devres automatically frees
the memory backing the parent domain.
Can this leave a dangling pointer in the global gpd_list that could trigger a
use-after-free or kernel panic when the list is next traversed, such as
during pm_genpd_poweroff_unused()? Should rockchip_pm_domain_cleanup() be
updated to iterate backwards to ensure children are removed before their
parents?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260912065053.1519165-1-gahing@gahingwoo.com?part=10
next prev parent reply other threads:[~2026-09-12 7:04 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-12 6:50 [PATCH v12 00/14] accel/rocket: RK3576 NPU (RKNN) enablement Jiaxing Hu
2026-09-12 6:50 ` [PATCH v12 01/14] accel/rocket: request the core clocks by name Jiaxing Hu
2026-09-12 7:03 ` sashiko-bot
2026-09-12 6:50 ` [PATCH v12 02/14] accel/rocket: take the completion register writes under job_lock Jiaxing Hu
2026-09-12 7:04 ` sashiko-bot
2026-09-12 6:50 ` [PATCH v12 03/14] accel/rocket: wait for a running IRQ handler before resetting a core Jiaxing Hu
2026-09-12 7:09 ` sashiko-bot
2026-09-12 11:37 ` Igor Paunovic
2026-09-12 22:48 ` Jiaxing Hu
2026-09-13 0:13 ` Igor Paunovic
2026-09-12 6:50 ` [PATCH v12 04/14] accel/rocket: let the core suspend after a reset Jiaxing Hu
2026-09-12 7:04 ` sashiko-bot
2026-09-12 6:50 ` [PATCH v12 05/14] accel/rocket: factor the completion tail out of the IRQ handler Jiaxing Hu
2026-09-12 7:05 ` sashiko-bot
2026-09-12 6:50 ` [PATCH v12 06/14] dt-bindings: npu: rockchip: add rockchip, rk3576-rknn-core Jiaxing Hu
2026-09-12 6:50 ` [PATCH v12 07/14] dt-bindings: power: rockchip: allow resets in a power domain node Jiaxing Hu
2026-09-12 6:50 ` [PATCH v12 08/14] dt-bindings: iommu: rockchip: describe the RK3576 NPU MMU Jiaxing Hu
2026-09-12 7:02 ` sashiko-bot
2026-09-12 6:50 ` [PATCH v12 09/14] pmdomain: rockchip: add optional per-domain power-on settle delay Jiaxing Hu
2026-09-12 7:09 ` sashiko-bot
2026-09-12 6:50 ` [PATCH v12 10/14] pmdomain: rockchip: cycle optional power-domain resets on power-on Jiaxing Hu
2026-09-12 7:04 ` sashiko-bot [this message]
2026-09-12 6:50 ` [PATCH v12 11/14] accel/rocket: select the per-core clock and reset counts from match data Jiaxing Hu
2026-09-12 7:06 ` sashiko-bot
2026-09-12 6:50 ` [PATCH v12 12/14] accel/rocket: add RK3576 NPU (RKNN) support Jiaxing Hu
2026-09-12 7:22 ` sashiko-bot
2026-09-12 6:50 ` [PATCH v12 13/14] arm64: dts: rockchip: add NPU (RKNN) nodes to rk3576 Jiaxing Hu
2026-09-12 6:50 ` [PATCH v12 14/14] arm64: dts: rockchip: enable the NPU on rk3576-rock-4d Jiaxing Hu
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=20260912070428.1FC671F00898@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=gahing@gahingwoo.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).