All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Jiawen Liu" <liu1298662399@gmail.com>
Cc: imx@lists.linux.dev, Frank.Li@kernel.org
Subject: Re: [PATCH] pmdomain: imx: gpc: Abort power-on on reset clock failure
Date: Sun, 29 Nov 2026 19:43:21 +0000	[thread overview]
Message-ID: <sashiko-outbox-239979@kernel.org> (raw)
In-Reply-To: <179598034233.2.15063208684049946861.pattern-ext-127.22@gmail.com>

Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [Critical] pmdomain: imx-gpc: use-after-free in imx_gpc_remove() [1]
--

commit 314d832218e82ea8e0176b8a53e992fc9028e2c4
Author: Jiawen Liu <liu1298662399@gmail.com>

pmdomain: imx: gpc: Abort power-on on reset clock failure

This commit aborts domain power-on in imx6_pm_domain_power_on() if
clk_prepare_enable() fails, unwinding enabled clocks and the domain supply
regulator and propagating the error to both DT initialization paths.

> diff --git a/drivers/pmdomain/imx/gpc.c b/drivers/pmdomain/imx/gpc.c
> index e0027459ad588..5e70997eb135b 100644
> --- a/drivers/pmdomain/imx/gpc.c
> +++ b/drivers/pmdomain/imx/gpc.c

[ ... ]

> @@ -394,6 +411,7 @@ static int imx_gpc_old_dt_init(struct device *dev, struct regmap *regmap,
>  genpd_err:
>  	for (i = 0; i < num_domains; i++)
>  		pm_genpd_remove(&imx_gpc_domains[i].base);
> +put_clocks:
>  	imx_pgc_put_clocks(&imx_gpc_domains[GPC_PGC_DOMAIN_PU]);
>  clk_err:
>  	return ret;

[Severity: Critical]
This problem wasn't introduced by this patch, but in the paired teardown
path imx_gpc_remove() [1], can an early return when pm_genpd_remove()
fails leave imx_gpc_domains[] registered after devm resources are freed?

drivers/pmdomain/imx/gpc.c:imx_gpc_remove() {
    ...
		while (num_domains--) {
			ret = pm_genpd_remove(&imx_gpc_domains[num_domains].base);
			if (ret) {
				dev_err(&pdev->dev,
					"Failed to remove %s power domain (%pe)\n",
					imx_gpc_domains[num_domains].base.name,
					ERR_PTR(ret));
				return;
			}

			if (num_domains == GPC_PGC_DOMAIN_PU)
				imx_pgc_put_clocks(&imx_gpc_domains[num_domains]);
		}
    ...
}

Because imx_gpc_remove() returns void, returning early does not abort device
unbind.  The driver core still releases devm-managed resources such as the
domain regmap and supply regulator, so later genpd operations on the
remaining registered domains can trigger a use-after-free, and the PU domain
clocks are leaked.

[1] https://sashiko.dev/#/bug/linux-dc541c69-9965-4302-ab98-59f2bf3c23ca

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/179598034233.2.15063208684049946861.pattern-ext-127.22@gmail.com?part=1

      reply	other threads:[~2026-11-29 19:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-29 19:25 [PATCH] pmdomain: imx: gpc: Abort power-on on reset clock failure Jiawen Liu
2026-11-29 19:43 ` sashiko-bot [this message]

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-239979@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=imx@lists.linux.dev \
    --cc=liu1298662399@gmail.com \
    --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.