summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell King (Oracle) <rmk+kernel@armlinux.org.uk>2024-05-27 09:00:06 +0100
committerRussell King (Oracle) <rmk+kernel@armlinux.org.uk>2024-06-04 17:12:01 +0100
commit616501eccb58615f8f352a29239ea6c6fc5e6546 (patch)
tree4476370e39cb2433755acf4d9eddb8d43faf7b19
parent8d532528ff6a6b1bccf648d0f5713188e292ce8f (diff)
clkdev: don't fail clkdev_alloc() if over-sized
Don't fail clkdev_alloc() if the strings are over-sized. In this case, the entry will not match during lookup, so its useless. However, since code fails if we return NULL leading to boot failure, return a dummy entry with the connection and device IDs set to "bad". Leave the warning so these problems can be found, and the useless wasteful clkdev registrations removed. Reported-by: Ron Economos <re@w6rz.net> Reported-by: Guenter Roeck <linux@roeck-us.net> Fixes: 8d532528ff6a ("clkdev: report over-sized strings when creating clkdev entries") Closes: https://lore.kernel.org/linux-clk/7eda7621-0dde-4153-89e4-172e4c095d01@roeck-us.net. Link: https://lore.kernel.org/r/28114882-f8d7-21bf-4536-a186e8d7a22a@w6rz.net Tested-by: Ron Economos <re@w6rz.net> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
-rw-r--r--drivers/clk/clkdev.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c
index 56a12f1da472..476fb9b7adb5 100644
--- a/drivers/clk/clkdev.c
+++ b/drivers/clk/clkdev.c
@@ -204,8 +204,15 @@ fail:
pr_err("%pV:%s: %s ID is greater than %zu\n",
&vaf, con_id, failure, max_size);
va_end(ap_copy);
- kfree(cla);
- return NULL;
+
+ /*
+ * Don't fail in this case, but as the entry won't ever match just
+ * fill it with something that also won't match.
+ */
+ strscpy(cla->con_id, "bad", sizeof(cla->con_id));
+ strscpy(cla->dev_id, "bad", sizeof(cla->dev_id));
+
+ return &cla->cl;
}
static struct clk_lookup *