Re: [PATCH v1] clk: devres: fix cleanup in devm_clk_get_optional_enabled_with_rate()

From: Stephen Boyd

Date: Fri Aug 14 2026 - 01:41:32 EST


Quoting Onur Özkan (2026-08-01 04:16:34)
> devm_clk_get_optional_enabled_with_rate() registers its cleanup action
> before setting the clock rate. If setting the rate fails, it attempts to
> disable and unprepare a clock that was never enabled. This issue was
> spotted while reviewing "rust: clk: add devres-managed clks" [1].
>
> Register the cleanup action only after successfully preparing and enabling
> the clock.
>
> [1]: https://lore.kernel.org/rust-for-linux/20260706-clk-type-state-v5-3-67c5f326a16c@xxxxxxxxxxxxx
>
> Fixes: 9934a1bd45b2 ("clk: provide devm_clk_get_optional_enabled_with_rate()")
> Signed-off-by: Onur Özkan <work@xxxxxxxxxxxxx>
> ---

Applied to clk-next