mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Baek Kyu, Kim" <pocj8ur4in@gmail.com>
To: sboyd@kernel.org, bmasney+clk@redhat.com, jbrunet+clk@baylibre.com
Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Baek Kyu, Kim" <pocj8ur4in@gmail.com>
Subject: [PATCH] clk: devres: Skip cleanup action for absent optional clocks
Date: Sun, 18 Oct 2026 15:30:09 +0900	[thread overview]
Message-ID: <20261018063009.1365568-1-pocj8ur4in@gmail.com> (raw)

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


                 reply	other threads:[~2026-10-18  6:30 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20261018063009.1365568-1-pocj8ur4in@gmail.com \
    --to=pocj8ur4in@gmail.com \
    --cc=bmasney+clk@redhat.com \
    --cc=jbrunet+clk@baylibre.com \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sboyd@kernel.org \
    /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

all inboxes | Powered by JetHome®