From: sashiko-bot@kernel.org
To: evon.chiam@altera.com
Cc: robh@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH 5/5] arm64: dts: altera: agilex72: add clock manager support
Date: Thu, 06 Aug 2026 09:40:38 +0000 [thread overview]
Message-ID: <20260806094039.3BE071F000E9@smtp.kernel.org> (raw)
In-Reply-To: <394c5838c535f939361da220ad94c9aec7fea973.1786006669.git.evon.chiam@altera.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Clock gate operations (.enable, .disable, .is_enabled) are missing from gateclk_ops, rendering clock gating non-functional.
- [High] Probe error path leaves non-devm clocks registered with CCF while their backing MMIO regions are unmapped, leading to a use-after-free panic.
--
--- Patch [5]: [PATCH 5/5] arm64: dts: altera: agilex72: add clock manager support ---
commit 9ede61d9f11826e0bfb7cdf0bab36155fec8e509
Author: Chiam, Evon <evon.chiam@altera.com>
arm64: dts: altera: agilex72: add clock manager support
Add the Agilex72 clock manager node and input reference clocks, and
wire the UART clocks through the clock manager instead of a fixed
clock. Set the SoCDK board-specific input clock frequencies.
> diff --git a/drivers/clk/socfpga/clk-agilex72.c b/drivers/clk/socfpga/clk-agilex72.c
> new file mode 100644
> index 0000000000000..e350d8a9bb4d9
> --- /dev/null
> +++ b/drivers/clk/socfpga/clk-agilex72.c
> @@ -0,0 +1,1181 @@
[ ... ]
> +static const struct clk_ops peri_cnt_clk_ops = {
> + .recalc_rate = agilex72_clk_peri_cnt_clk_recalc_rate,
> + .get_parent = agilex72_clk_periclk_get_parent,
> +};
> +
> +static const struct clk_ops gateclk_ops = {
> + .recalc_rate = agilex72_gate_clk_recalc_rate,
> + .get_parent = agilex72_gate_get_parent,
> +};
[Severity: High]
Since gateclk_ops omits the standard clock gating callbacks like .enable,
.disable, and .is_enabled, won't this prevent the kernel from toggling hardware
gates?
If a peripheral's clock was disabled by the bootloader, calling
clk_prepare_enable() from a driver will silently return success without
modifying the hardware. Subsequent register accesses to that peripheral could
trigger a synchronous external abort.
[ ... ]
> + init.ops = &gateclk_ops;
> +
> + init.name = clks->name;
> + init.flags = 0;
> + init.num_parents = clks->num_parents;
> + init.parent_names = clks->parent_names;
> + socfpga_clk->hw.hw.init = &init;
> +
> + hw_clk = &socfpga_clk->hw.hw;
> +
> + ret = clk_hw_register(NULL, &socfpga_clk->hw.hw);
> + if (ret) {
> + kfree(socfpga_clk);
> + return ERR_PTR(ret);
> + }
> + return hw_clk;
> +}
[Severity: High]
Individual clocks are registered into the Common Clock Framework using
clk_hw_register() here without being tied to the device's devres lifecycle.
If devm_clk_hw_register_fixed_factor() fails later during
agilex72_clkmgr_init(), the probe will abort and the devres framework will
automatically unmap the MMIO bases.
However, these non-devm clocks registered earlier will not be unregistered.
Could this leave dangling pointers in the CCF?
[ ... ]
> + /*
> + * usb31_ref_clk is a 1:1 alias of usb31_suspend_clk. The DWC3
> + * controller uses the same source for both its suspend and reference
> + * clock inputs on this SoC. Register it as a fixed-factor (passthrough)
> + * clock so that enabling it propagates to the parent gate without
> + * touching any gate register of its own.
> + */
> + clk_data->clk_data.hws[AGILEX72_USB31_REF_CLK] =
> + devm_clk_hw_register_fixed_factor(dev, "usb31_ref_clk",
> + "usb31_suspend_clk", 0, 1, 1);
> + if (IS_ERR(clk_data->clk_data.hws[AGILEX72_USB31_REF_CLK]))
> + return dev_err_probe(dev,
> + PTR_ERR(clk_data->clk_data.hws[AGILEX72_USB31_REF_CLK]),
> + "failed to register clock usb31_ref_clk\n");
[Severity: High]
This error path fails the probe without unregistering the previously registered
non-devm clocks.
If CCF later walks the clock tree (e.g., via a read of
/sys/kernel/debug/clk/clk_summary), it will invoke the .recalc_rate callbacks
of these leaked clocks. Those callbacks will dereference the now-unmapped memory
pointers, causing an external abort/kernel panic.
Is there a way to unregister them to avoid leaving dangling pointers, or should
devm_clk_hw_register() be used for all clocks?
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1786006669.git.evon.chiam@altera.com?part=5
prev parent reply other threads:[~2026-08-06 9:40 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-06 9:25 [PATCH 0/5] clk: socfpga: add Agilex72 clock manager support evon.chiam
2026-08-06 9:25 ` [PATCH 1/5] dt-bindings: arm: altera: fix Agilex72 compatible vendor prefix evon.chiam
2026-08-06 9:33 ` sashiko-bot
2026-08-06 9:25 ` [PATCH 2/5] dt-bindings: clock: altr,agilex72-clkmgr: add Agilex72 clock manager binding evon.chiam
2026-08-06 9:34 ` sashiko-bot
2026-08-06 9:25 ` [PATCH 3/5] clk: socfpga: agilex72: add clock manager driver for Agilex72 evon.chiam
2026-08-06 9:38 ` sashiko-bot
2026-08-06 9:25 ` [PATCH 4/5] arm64: dts: altera: move Agilex72 DT and use altr prefix evon.chiam
2026-08-06 9:40 ` sashiko-bot
2026-08-06 9:25 ` [PATCH 5/5] arm64: dts: altera: agilex72: add clock manager support evon.chiam
2026-08-06 9:40 ` 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=20260806094039.3BE071F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=evon.chiam@altera.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