From: yong.liu <binary_world@163.com>
To: Stephen Boyd <sboyd@kernel.org>,
Brian Masney <bmasney+clk@redhat.com>,
Jerome Brunet <jbrunet+clk@baylibre.com>
Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org,
binary_world@163.com
Subject: [PATCH] clk: Reject positive return values from init callbacks
Date: Wed, 23 Sep 2026 03:58:34 GMT [thread overview]
Message-ID: <ccf-patch-f7a5fae0-beeb-4667-93c7-3a4ce9321890@163.com> (raw)
Clock init callbacks must return zero on success or a negative error code
on failure. If a callback returns a positive value, __clk_core_init()
already takes its failure path and __clk_register() releases the clock
before returning ERR_PTR(ret).
However, a positive value encoded by ERR_PTR() is not recognized by
IS_ERR(). Consequently, clk_register() returns an invalid pointer that
passes the caller's error check, while clk_hw_register() and
of_clk_hw_register() report success through PTR_ERR_OR_ZERO() despite
registration having failed.
Convert positive init return values to -EINVAL before taking the failure
path. This makes the registration failure detectable through the public
registration interfaces while preserving valid negative error codes.
Signed-off-by: yong.liu <binary_world@163.com>
---
drivers/clk/clk.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -4053,6 +4053,8 @@ static int __clk_core_init(struct clk_core *core)
*/
if (core->ops->init) {
ret = core->ops->init(core->hw);
+ if (ret > 0)
+ ret = -EINVAL;
if (ret)
goto out;
}
next reply other threads:[~2026-09-23 3:59 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-23 3:58 yong.liu [this message]
2026-09-23 8:42 ` Jerome Brunet
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=ccf-patch-f7a5fae0-beeb-4667-93c7-3a4ce9321890@163.com \
--to=binary_world@163.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®