[PATCH v1 04/10] clk: tolerate clocks registered without a name

Oleksij Rempel o.rempel at pengutronix.de
Thu Jun 11 22:59:20 PDT 2026


From: Ahmad Fatoum <a.fatoum at barebox.org>

bclk_register() crashes when ->name is NULL because __bclk_register()
strdup()s it unconditionally. Reject such registrations early with
-EINVAL instead of taking down the system, so a buggy driver only
fails its own clock instead of the whole boot.

Signed-off-by: Ahmad Fatoum <a.fatoum at barebox.org>
Signed-off-by: Oleksij Rempel <o.rempel at pengutronix.de>
---
 drivers/clk/clk.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 5e385380cee2..99f995fb0224 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -494,6 +494,9 @@ int bclk_register(struct clk *clk)
 
 	clk->parents = xzalloc(sizeof(struct clk *) * clk->num_parents);
 
+	if (!clk->name)
+		return -EINVAL;
+
 	ret = __bclk_register(clk);
 	if (ret)
 		free(clk->parents);
-- 
2.47.3




More information about the barebox mailing list