Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Abel Vesa" <abel.vesa@oss.qualcomm.com>
Cc: linux-clk@vger.kernel.org, robh@kernel.org,
	devicetree@vger.kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH 02/16] clk: qcom: gcc-sm8350: Tie the CX power domain to controller
Date: Wed, 19 Aug 2026 13:12:05 +0000	[thread overview]
Message-ID: <20260819131205.BCE521F00A3D@smtp.kernel.org> (raw)
In-Reply-To: <20260819-qcom-tie-cx-to-gcc-v1-2-840034124e73@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Resource leak and Use-After-Free (UAF) in generic power domain registration error paths.
--

--- Patch [2]: [PATCH 02/16] clk: qcom: gcc-sm8350: Tie the CX power domain to controller ---
commit 2f90d172dae6e2aec9b20b94ed643f0031c58164
Author: Abel Vesa <abel.vesa@oss.qualcomm.com>

clk: qcom: gcc-sm8350: Tie the CX power domain to controller

Enable runtime PM for the controller so the common GCC probe path resumes
the attached domain while registering clocks, resets and GDSCs.

> diff --git a/drivers/clk/qcom/gcc-sm8350.c b/drivers/clk/qcom/gcc-sm8350.c
> index 2d94f3046b711..996ee8592fabe 100644
> --- a/drivers/clk/qcom/gcc-sm8350.c
> +++ b/drivers/clk/qcom/gcc-sm8350.c
> @@ -3786,6 +3786,7 @@ static const struct qcom_cc_desc gcc_sm8350_desc = {
>  	.resets = gcc_sm8350_resets,
>  	.num_resets = ARRAY_SIZE(gcc_sm8350_resets),
>  	.gdscs = gcc_sm8350_gdscs,
> +	.use_rpm = true,

[Severity: High]
This is a pre-existing issue, but since this patch relies on the GDSC
infrastructure, is there a risk of a use-after-free during error handling
in the core GDSC registration?

Looking at gdsc_register() in drivers/clk/qcom/gdsc.c, if a failure occurs
during gdsc_init(), the function returns directly:

drivers/clk/qcom/gdsc.c:gdsc_register() {
    ...
        ret = gdsc_init(scs[i]);
        if (ret)
            return ret;
    ...
}

Similarly, if of_genpd_add_provider_onecell() fails, it returns without
unregistering the initialized domains:

drivers/clk/qcom/gdsc.c:gdsc_register() {
    ...
    return of_genpd_add_provider_onecell(dev->of_node, data);

err_pm_subdomain_remove:
    gdsc_pm_subdomain_remove(desc, i);

    return ret;
}

Because pm_genpd_remove() is not called on these error paths, the domains
remain linked in the global gpd_list.

When the probe fails, devres will clean up managed resources like regmap.
Later, when the genpd framework invokes pd->power_off() (such as via
genpd_power_off_unused() at late_initcall), it calls gdsc_disable() which
could dereference these freed devres-managed pointers.

Should gdsc_register() be updated to unregister the power domains on these
error paths to prevent dangling pointers?

>  	.num_gdscs = ARRAY_SIZE(gcc_sm8350_gdscs),
>  };

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260819-qcom-tie-cx-to-gcc-v1-0-840034124e73@oss.qualcomm.com?part=2

  reply	other threads:[~2026-08-19 13:12 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-19 12:51 [PATCH 00/16] clk: qcom: Tie CX power domains to GCCs Abel Vesa
2026-08-19 12:51 ` [PATCH 01/16] clk: qcom: gcc-sm8250: Tie the CX power domain to controller Abel Vesa
2026-08-19 15:25   ` Konrad Dybcio
2026-08-19 12:51 ` [PATCH 02/16] clk: qcom: gcc-sm8350: " Abel Vesa
2026-08-19 13:12   ` sashiko-bot [this message]
2026-08-19 12:51 ` [PATCH 03/16] clk: qcom: gcc-sm8450: " Abel Vesa
2026-08-19 13:15   ` sashiko-bot
2026-08-19 12:51 ` [PATCH 04/16] clk: qcom: gcc-sm8550: " Abel Vesa
2026-08-19 12:51 ` [PATCH 05/16] clk: qcom: gcc-sm8650: " Abel Vesa
2026-08-19 12:51 ` [PATCH 06/16] clk: qcom: gcc-sm8750: " Abel Vesa
2026-08-19 12:51 ` [PATCH 07/16] clk: qcom: gcc-kaanapali: " Abel Vesa
2026-08-19 12:51 ` [PATCH 08/16] clk: qcom: gcc-qcs615: " Abel Vesa
2026-08-19 12:51 ` [PATCH 09/16] arm64: dts: qcom: sm8250: Add GCC CX power domain Abel Vesa
2026-08-19 13:08   ` sashiko-bot
2026-08-19 12:51 ` [PATCH 10/16] arm64: dts: qcom: sm8350: " Abel Vesa
2026-08-19 13:05   ` sashiko-bot
2026-08-19 12:51 ` [PATCH 11/16] arm64: dts: qcom: sm8450: " Abel Vesa
2026-08-19 12:51 ` [PATCH 12/16] arm64: dts: qcom: sm8550: " Abel Vesa
2026-08-19 13:03   ` sashiko-bot
2026-08-19 12:51 ` [PATCH 13/16] arm64: dts: qcom: sm8650: " Abel Vesa
2026-08-19 13:09   ` sashiko-bot
2026-08-19 12:51 ` [PATCH 14/16] arm64: dts: qcom: sm8750: " Abel Vesa
2026-08-19 12:52 ` [PATCH 15/16] arm64: dts: qcom: kaanapali: " Abel Vesa
2026-08-19 12:52 ` [PATCH 16/16] arm64: dts: qcom: talos: " Abel Vesa

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=20260819131205.BCE521F00A3D@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=abel.vesa@oss.qualcomm.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-clk@vger.kernel.org \
    --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