From: sashiko-bot@kernel.org
To: "Dan Carpenter" <error27@gmail.com>
Cc: linux-clk@vger.kernel.org
Subject: Re: [PATCH 1/1] clk: Document of_clk_get_by_name() return values
Date: Tue, 15 Sep 2026 16:49:12 +0000 [thread overview]
Message-ID: <20260915164913.597D51F000FF@smtp.kernel.org> (raw)
In-Reply-To: <b3de48fdbaaade69cce126b59bd6dfb8f437b495.1789451862.git.error27@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] clk: false claim in of_clk_get_by_name() documentation
--
commit d09131dbb97111f2e3801d98bcbd5fbb8288397d
Author: Dan Carpenter <error27@gmail.com>
clk: Document of_clk_get_by_name() return values
This commit documents the return values for of_clk_get_by_name(), stating
that it returns a valid clock on success or an error pointer on failure. It
also explicitly claims that the function never returns NULL.
> diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
> index fef87167a60b5..7e1a88c3837a3 100644
> --- a/drivers/clk/clk.c
> +++ b/drivers/clk/clk.c
> @@ -5420,6 +5420,9 @@ EXPORT_SYMBOL(of_clk_get);
> * This function parses the clocks and clock-names properties,
> * and uses them to look up the struct clk from the registered list of clock
> * providers.
> + *
> + * Returns: A clock pointer on success or an error pointer on failure. This
> + * function never returns NULL.
> */
> struct clk *of_clk_get_by_name(struct device_node *np, const char *name)
> {
[Severity: Medium]
Is it accurate that this function never returns NULL?
It appears of_clk_get_by_name() delegates to of_clk_get_hw_from_clkspec(),
which invokes the clock provider's get_hw callback. Providers often use
of_clk_hw_onecell_get() with sparse clock arrays (such as
struct clk_hw_onecell_data) where uninitialized entries are NULL.
When such an entry is requested, NULL propagates back through
clk_hw_create_clk() (which uses ERR_CAST(NULL)), causing
of_clk_get_by_name() to return NULL on success.
Could this documentation mislead driver developers into removing NULL checks
or introducing assertions (e.g., BUG_ON(!clk)) that will crash the kernel
when a valid dummy clock is returned?
--
Sashiko AI review · https://sashiko.dev/#/patchset/b3de48fdbaaade69cce126b59bd6dfb8f437b495.1789451862.git.error27@gmail.com?part=1
next prev parent reply other threads:[~2026-09-15 16:49 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cover.1789451862.git.error27@gmail.com>
2026-09-15 16:38 ` [PATCH 1/1] clk: Document of_clk_get_by_name() return values Dan Carpenter
2026-09-15 16:49 ` sashiko-bot [this message]
2026-09-15 17:53 ` Dan Carpenter
2026-09-15 17:58 ` Dan Carpenter
2026-09-16 7:28 ` Jerome Brunet
2026-09-16 7:49 ` Dan Carpenter
2026-09-16 14:22 ` 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=20260915164913.597D51F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=error27@gmail.com \
--cc=linux-clk@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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