Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Patrick Delaunay" <patrick.delaunay@foss.st.com>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v3 4/7] arm64: dts: st: add D1 domain for STM32MP25 family
Date: Thu, 03 Dec 2026 19:08:46 +0000	[thread overview]
Message-ID: <sashiko-outbox-248468@kernel.org> (raw)
In-Reply-To: <20261203181556.v3.4.I1233f0c68bba42732eb6dc470b5eebaf6db441a7@changeid>

Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Medium] pmdomain: st: OF node reference leak in
  stm32mp_pm_domain_probe()
- [Medium] pmdomain: st: UAF on d1_pd unbind when pm_genpd_remove()
  returns -EBUSY
- [Low] arm64: dts: st: undocumented RET_PD power-domains assignment on
  hpdma1-3
--

commit 4d68b237fb4210955e34085639d48ea0038b974b
Author: Patrick Delaunay <patrick.delaunay@foss.st.com>

arm64: dts: st: add D1 domain for STM32MP25 family

This commit adds the d1_pd power-controller node to the STM32MP25 device
tree, assigns STM32MP25 peripherals to it, and assigns the HPDMA
controllers to RET_PD.

> diff --git a/arch/arm64/boot/dts/st/stm32mp251.dtsi b/arch/arm64/boot/dts/st/stm32mp251.dtsi
> index bf1542818be25..49bc5ca9cf710 100644
> --- a/arch/arm64/boot/dts/st/stm32mp251.dtsi
> +++ b/arch/arm64/boot/dts/st/stm32mp251.dtsi
> @@ -152,6 +152,12 @@ v2m0: v2m@48090000 {
>  		};
>  	};
>  
> +	d1_pd: power-controller {
> +		compatible = "st,stm32mp-pm-domain";
> +		#power-domain-cells = <0>;
> +		power-domains = <&CLUSTER_PD>;
> +	};
> +
>  	psci {
>  		compatible = "arm,psci-1.0";
>  		method = "smc";

[Severity: Medium]
Does activating st,stm32mp-pm-domain leak an OF node reference on
CLUSTER_PD in stm32mp_pm_domain_probe()?

In drivers/pmdomain/st/stm32mp-pm-domain.c, stm32mp_pm_domain_probe()
takes a reference on link->domain.np via of_parse_phandle_with_args().
Later error returns (such as -EPROBE_DEFER from of_genpd_add_subdomain())
and stm32mp_pm_domain_genpd_remove_subdomain() never call of_node_put().

Registering a devm action to release link->domain.np right after
of_parse_phandle_with_args() would cover both probe deferral and teardown.

[ ... ]

> @@ -209,6 +215,7 @@ hpdma: dma-controller@40400000 {
>  				     <GIC_SPI 47 IRQ_TYPE_LEVEL_HIGH>,
>  				     <GIC_SPI 48 IRQ_TYPE_LEVEL_HIGH>;
>  			clocks = <&scmi_clk CK_SCMI_HPDMA1>;
> +			power-domains = <&RET_PD>;
>  			#dma-cells = <3>;
>  		};

[Severity: Low]
Should the RET_PD assignment on hpdma, hpdma2, and hpdma3 be split into
its own commit or documented in the commit message?

The changelog only describes adding d1_pd and assigning peripherals to D1.
Because hpdma, hpdma2, and hpdma3 are enabled by default and stm32-dma3
holds runtime PM references while channels are allocated, attaching them
to RET_PD affects when RET_PD can power off during idle.

[ ... ]

> @@ -273,7 +282,7 @@ ommanager: ommanager@40500000 {
>  				 <&scmi_reset RST_SCMI_OSPI2>;
>  			reset-names = "omm", "ospi1", "ospi2";
>  			access-controllers = <&rifsc 111>;
> -			power-domains = <&CLUSTER_PD>;
> +			power-domains = <&d1_pd>;
>  			#address-cells = <2>;
>  			#size-cells = <1>;
>  			st,syscfg-amcr = <&syscfg 0x2c00 0x7>;

[Severity: Medium]
Can unbinding or unloading the stm32mp_pm_domain driver trigger a
use-after-free of pd now that STM32MP25 peripherals attach to d1_pd?

stm32mp_pm_domain_driver uses module_platform_driver() without setting
suppress_bind_attrs = true, and its devm teardown action
stm32mp_pm_domain_genpd_remove() discards the return value of
pm_genpd_remove().

If d1_pd is unbound while consumers remain attached (for example under
fw_devlink=off, where device links do not unbind consumers first),
genpd_remove() returns -EBUSY and leaves pd in gpd_list.  Devres then
frees pd, causing a use-after-free on the next genpd traversal or detach.

Setting suppress_bind_attrs = true and making the driver built-in would
avoid freeing a still-registered generic_pm_domain.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261203171721.1525015-1-patrick.delaunay@foss.st.com?part=4

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

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03 17:15 [PATCH v3 0/7] arm64: dts: st: add STM32MP2 power domains Patrick Delaunay
2026-12-03 17:15 ` [PATCH v3 1/7] dt-bindings: power: st: add STM32MP PM domain Patrick Delaunay
2026-12-03 18:19   ` sashiko-bot
2026-12-03 17:16 ` [PATCH v3 4/7] arm64: dts: st: add D1 domain for STM32MP25 family Patrick Delaunay
2026-12-03 19:08   ` sashiko-bot [this message]
2026-12-03 17:16 ` [PATCH v3 5/7] arm64: dts: st: fix power-domain labels DT coding style in STM32MP25 Patrick Delaunay
2026-12-03 17:16 ` [PATCH v3 6/7] arm64: dts: st: add D1 domain for STM32MP23 family Patrick Delaunay
2026-12-03 19:29   ` sashiko-bot
2026-12-03 17:16 ` [PATCH v3 7/7] arm64: dts: st: add power domains for STM32MP21 family Patrick Delaunay

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-248468@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=patrick.delaunay@foss.st.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