Re: [PATCH v1] clk: devres: fix cleanup in devm_clk_get_optional_enabled_with_rate()
From: Brian Masney
Date: Mon Aug 03 2026 - 09:35:20 EST
On Sat, Aug 01, 2026 at 02:16:34PM +0300, Onur Özkan wrote:
> 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>
Reviewed-by: Brian Masney <bmasney@xxxxxxxxxx>