* [PATCH] clk: handle get_parent callbacks returning an error
@ 2026-10-25 9:31 Ahmad Fatoum
2026-10-26 13:03 ` Sascha Hauer
0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2026-10-25 9:31 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] clk: handle get_parent callbacks returning an error
2026-10-25 9:31 [PATCH] clk: handle get_parent callbacks returning an error Ahmad Fatoum
@ 2026-10-26 13:03 ` Sascha Hauer
0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2026-10-26 13:03 UTC (permalink / raw)
To: barebox, Ahmad Fatoum
On Sun, 25 Oct 2026 10:31:20 +0100, Ahmad Fatoum wrote:
> 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.
>
> [...]
Applied, thanks!
[1/1] clk: handle get_parent callbacks returning an error
https://git.pengutronix.de/cgit/barebox/commit/?id=22f58f5dea50 (link may not be stable)
Best regards,
--
Sascha Hauer <s.hauer@pengutronix.de>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-10-26 13:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-25 9:31 [PATCH] clk: handle get_parent callbacks returning an error Ahmad Fatoum
2026-10-26 13:03 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox