* [PATCH] clk: devres: Skip cleanup action for absent optional clocks
@ 2026-10-18 6:30 Baek Kyu, Kim
0 siblings, 0 replies; only message in thread
From: Baek Kyu, Kim @ 2026-10-18 6:30 UTC (permalink / raw)
To: sboyd, bmasney+clk, jbrunet+clk; +Cc: linux-clk, linux-kernel, Baek Kyu, Kim
devm_clk_get_optional_enabled_with_rate() registers a disable/unprepare
action even when the optional lookup returns NULL. If allocating the
action fails, the error path calls devm_clk_put(dev, NULL), triggering
warnings in devm_clk_match() and devm_clk_put().
Return NULL after the lookup to skip the unnecessary action registration.
The state allocated by devm_clk_get_optional() is released when the
device is detached.
Fixes: 0d4d262c1664 ("clk: devres: fix cleanup in devm_clk_get_optional_enabled_with_rate()")
Signed-off-by: Baek Kyu, Kim <pocj8ur4in@gmail.com>
---
Tested with KUnit under ARM64 QEMU using a test clock provider and
failslab. Failing the action allocation for an absent clock triggers two
warnings before the fix; the fix skips that allocation. All nine tests
pass with the fix, including cleanup and error paths for a registered
clock. The fix was not tested on physical hardware.
drivers/clk/clk-devres.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/clk/clk-devres.c b/drivers/clk/clk-devres.c
index 4cc3863bd7da..35fa34a961e4 100644
--- a/drivers/clk/clk-devres.c
+++ b/drivers/clk/clk-devres.c
@@ -112,8 +112,8 @@ struct clk *devm_clk_get_optional_enabled_with_rate(struct device *dev,
int ret;
clk = devm_clk_get_optional(dev, id);
- if (IS_ERR(clk))
- return ERR_CAST(clk);
+ if (IS_ERR_OR_NULL(clk))
+ return clk;
ret = clk_set_rate(clk, rate);
if (ret)
base-commit: 58161ead29e50d70a317ea26b472e0c7508e69da
--
2.55.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-10-18 6:30 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-18 6:30 [PATCH] clk: devres: Skip cleanup action for absent optional clocks Baek Kyu, Kim
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®