From: Ahmad Fatoum <a.fatoum@barebox.org>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@barebox.org>
Subject: [PATCH] clk: handle get_parent callbacks returning an error
Date: Sun, 25 Oct 2026 10:31:20 +0100 [thread overview]
Message-ID: <20261025093121.2888368-1-a.fatoum@barebox.org> (raw)
A mux with a value table returns -EINVAL from get_parent when the
register holds a value missing from the table. clk_get_parent() only
rejected indices >= num_parents, so -EINVAL went on to index the
parents array as u8 234 and clk_dump crashed on the Amlogic G12 clock
controller.
Let's return -ENODEV for negative indices as well.
Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
drivers/clk/clk.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 99f995fb0224..1d6aaa46d9b1 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -382,7 +382,8 @@ struct clk *clk_get_parent(struct clk *clk)
idx = clk->ops->get_parent(hw);
- if (idx >= clk->num_parents)
+ /* an error means the register selects no known parent */
+ if (idx < 0 || idx >= clk->num_parents)
return ERR_PTR(-ENODEV);
} else {
idx = 0;
--
2.47.3
next reply other threads:[~2026-10-25 9:32 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-25 9:31 Ahmad Fatoum [this message]
2026-10-26 13:03 ` Sascha Hauer
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=20261025093121.2888368-1-a.fatoum@barebox.org \
--to=a.fatoum@barebox.org \
--cc=barebox@lists.infradead.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