Re: [PATCH 3/9] dt-bindings: soc: rockchip: grf: Allow a clock for the RK3588 PHP GRF

From: netdev-bot+sashiko

Date: Tue Nov 17 2026 - 12:36:46 EST


Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] The RK3588 PHP GRF clock is allowed but not required.

Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but there is a
pre-existing use-after-free in the error unwind of…

--

dt-bindings: soc: rockchip: grf: Allow a clock for the RK3588 PHP GRF

This patch changes the clocks conditional in the Rockchip GRF binding.
The rockchip,rk3588-php-grf compatible is now exempt from "clocks: false",
so the node can describe pclk_php_root and the syscon regmap can enable it.

> diff --git a/Documentation/devicetree/bindings/soc/rockchip/grf.yaml b/Documentation/devicetree/bindings/soc/rockchip/grf.yaml
> index e94c83d7c1383..2525eb51f13b0 100644
> --- a/Documentation/devicetree/bindings/soc/rockchip/grf.yaml
> +++ b/Documentation/devicetree/bindings/soc/rockchip/grf.yaml
> @@ -321,8 +321,16 @@ allOf:
> - clocks
>
> else:
> - properties:
> - clocks: false
> + if:
> + not:
> + properties:
> + compatible:
> + contains:
> + const: rockchip,rk3588-php-grf
> +
> + then:
> + properties:
> + clocks: false

[Severity: Low]
Should rockchip,rk3588-php-grf go into the enum in the if: branch above,
so that clocks is required and not just allowed?

The commit message says the PHP GRF is clocked from pclk_php_root, which
gets gated. The later patch "arm64: dts: rockchip: Add the PHP GRF clock on
RK3588" says PHP GRF accesses hang without it.

This block already handles GRFs that need a clock. rockchip,rk3588-vo-grf
and rockchip,rk3576-dcphy-grf are listed in the enum, which both allows and
requires clocks.

As written, a php_grf node without clocks still passes dtbs_check. At
runtime, of_syscon_register() treats a missing clock as optional:

drivers/mfd/syscon.c:of_syscon_register() {
...
clk = of_clk_get(np, 0);
if (IS_ERR(clk)) {
ret = PTR_ERR(clk);
/* clock is optional */
if (ret != -ENOENT)
goto err_clk;
...
}

On such a DT the regmap would never enable pclk_php_root. The StreamID
restore added later in the series ("soc: rockchip: grf: Restore the RK3588
PHP StreamIDs after system suspend") would also be skipped without any
warning.

If the clock is meant to stay optional for older DTBs, could the commit
message say so? The binding also doesn't say which clock is expected. There
is no items list or description naming pclk_php_root.

[Severity: High]
This is a pre-existing issue and was not introduced by this patch. With
this series, php_grf goes through the clock-attached path in
of_syscon_register(). Is there a use-after-free of the struct clk in that
function's error unwind?

regmap_mmio_attach_clk() stores the clk in the regmap context before it
prepares it:

drivers/base/regmap/regmap-mmio.c:regmap_mmio_attach_clk() {
ctx->clk = clk;
ctx->attached_clk = true;

return clk_prepare(ctx->clk);
}

Two failures reach err_attach_clk: clk_prepare() failing, or
of_reset_control_get_optional_exclusive() returning an error. For example,
the reset lookup returns -EPROBE_DEFER if the reset controller hasn't
probed yet. The unwind is:

err_attach_clk:
if (!IS_ERR(clk))
clk_put(clk);
err_clk:
regmap_exit(regmap);

clk_put() frees the struct clk through __clk_put()->free_clk(). After that,
regmap_exit()->regmap_mmio_free_context() still uses the stored pointer:

if (!IS_ERR(ctx->clk)) {
clk_unprepare(ctx->clk);
...

clk_unprepare() then reads clk->core from the freed object. If
clk_prepare() was the step that failed, it also unprepares a clock that was
never prepared.

Would it fix this to detach the clock from the regmap, or to call
regmap_exit(), before clk_put()?

The php_grf node has no resets, so for php_grf only a clk_prepare() failure
can reach this path. Any syscon node with both clocks and resets is
affected. Syscon registration is retried on every lookup, so the path can
run repeatedly. The unwind comes from a00406b71c5f ("mfd: syscon: Add
optional clock support") and 7d1e3bd94828 ("mfd: syscon: Allow reset
control for syscon devices").

--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261113-mmu600-php-v1-0-231196049a3b%40gmail.com