[PATCH v2 4/9] clk: tolerate clocks registered without a name

Oleksij Rempel <[email protected]>
Newsgroups org.infradead.lists.barebox
Message-ID <[email protected]>
From: Ahmad Fatoum <[email protected]>

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 <[email protected]>
Signed-off-by: Oleksij Rempel <[email protected]>
---
Link to v1: https://lore.barebox.org/barebox/[email protected]/

Changes v2:
- no changes
---
 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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.