All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Neil Armstrong" <neil.armstrong@linaro.org>
Cc: conor+dt@kernel.org, robh@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v2 4/6] arm64: dts: qcom: sm8450: Add missing CX power domain to GCC
Date: Mon, 15 Jun 2026 17:10:06 +0000	[thread overview]
Message-ID: <20260615171006.88CAB1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260615-topic-sm8x50-tie-gcc-to-cx-v2-4-6b5752dd4747@linaro.org>

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

Pre-existing issues:
- [High] Missing `pm_genpd_remove()` and error path cleanup in `gdsc_register()` leads to use-after-free in `gpd_list` upon unbind or probe failure.
--

commit e4315c043469a13f84ee75ac94f4e0790692142c
Author: Neil Armstrong <neil.armstrong@linaro.org>

arm64: dts: qcom: sm8450: Add missing CX power domain to GCC

This commit associates the GCC with RPMHPD_CX by adding a power-domains
property to the device tree, preventing under-voltage conditions by allowing
votes to propagate.

> diff --git a/arch/arm64/boot/dts/qcom/sm8450.dtsi b/arch/arm64/boot/dts/qcom/sm8450.dtsi
> --- a/arch/arm64/boot/dts/qcom/sm8450.dtsi
> +++ b/arch/arm64/boot/dts/qcom/sm8450.dtsi
> @@ -935,6 +935,7 @@ soc: soc@0 {
>  		gcc: clock-controller@100000 {
>  			compatible = "qcom,gcc-sm8450";
>  			reg = <0x0 0x00100000 0x0 0x1f4200>;
> +			power-domains = <&rpmhpd RPMHPD_CX>;

[Severity: High]
This is a pre-existing issue, but since this patch configures the power
domains for this device, it brings up a concern in the underlying Qualcomm
GDSC driver framework.

If probe fails or the module is unloaded, does the error handling in
gdsc_register() leave dangling pointers in the core gpd_list?

Looking at drivers/clk/qcom/gdsc.c:gdsc_register(), if a subsequent
gdsc_init() fails, it returns directly:

drivers/clk/qcom/gdsc.c:gdsc_register() {
    for (i = 0; i < num; i++) {
        if (!scs[i])
            continue;
        ...
        ret = gdsc_init(scs[i]);
        if (ret)
            return ret;
    }
}

This seems to leak the previously initialized power domains in the global
gpd_list because it misses calling pm_genpd_remove() for scs[0..i-1].

Similarly, if of_genpd_add_provider_onecell() fails at the end of the
function, it also returns immediately or bypasses domain removal:

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;
}

Furthermore, gdsc_unregister() removes subdomains and deletes the provider,
but entirely misses pm_genpd_remove() before the backing memory is freed
on module unload:

drivers/clk/qcom/gdsc.c:gdsc_unregister() {
    ...
    gdsc_pm_subdomain_remove(desc, num);
    of_genpd_del_provider(dev->of_node);
}

Could this result in a use-after-free kernel panic if gpd_list is iterated
(for example, by genpd_power_off_unused() or debugfs) after an unbind or
probe failure?

>  			#clock-cells = <1>;
>  			#reset-cells = <1>;
>  			#power-domain-cells = <1>;

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260615-topic-sm8x50-tie-gcc-to-cx-v2-0-6b5752dd4747@linaro.org?part=4

  reply	other threads:[~2026-06-15 17:10 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-15 16:57 [PATCH v2 0/6] arm64: dts: qcom: sm8[456]50: Add missing CX power domain to GCC Neil Armstrong
2026-06-15 16:57 ` [PATCH v2 1/6] dt-bindings: clock: qcom: gcc-sm8450: Add missing power-domains property Neil Armstrong
2026-06-15 19:02   ` sashiko-bot
2026-06-15 16:57 ` [PATCH v2 2/6] dt-bindings: clock: qcom: sm8550-gcc: " Neil Armstrong
2026-06-15 17:03   ` sashiko-bot
2026-06-15 16:57 ` [PATCH v2 3/6] dt-bindings: clock: qcom: sm8650-gcc: " Neil Armstrong
2026-06-15 17:05   ` sashiko-bot
2026-06-15 16:57 ` [PATCH v2 4/6] arm64: dts: qcom: sm8450: Add missing CX power domain to GCC Neil Armstrong
2026-06-15 17:10   ` sashiko-bot [this message]
2026-06-15 16:57 ` [PATCH v2 5/6] arm64: dts: qcom: sm8550: " Neil Armstrong
2026-06-15 16:57 ` [PATCH v2 6/6] arm64: dts: qcom: sm8650: " Neil Armstrong

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=20260615171006.88CAB1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=neil.armstrong@linaro.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 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.