]> Git Repo - J-linux.git/commitdiff
clkdev: don't fail clkdev_alloc() if over-sized
authorRussell King (Oracle) <[email protected]>
Mon, 27 May 2024 08:00:06 +0000 (09:00 +0100)
committerRussell King (Oracle) <[email protected]>
Tue, 4 Jun 2024 16:12:01 +0000 (17:12 +0100)
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 <[email protected]>
Reported-by: Guenter Roeck <[email protected]>
Fixes: 8d532528ff6a ("clkdev: report over-sized strings when creating clkdev entries")
Closes: https://lore.kernel.org/linux-clk/[email protected].
Link: https://lore.kernel.org/r/[email protected]
Tested-by: Ron Economos <[email protected]>
Signed-off-by: Russell King (Oracle) <[email protected]>
drivers/clk/clkdev.c

index 56a12f1da472d70f9a504b49a13c7a5fb5f5b793..476fb9b7adb5ed57cc3c6a4eb5e0abdb7addda01 100644 (file)
@@ -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 *
This page took 0.050286 seconds and 4 git commands to generate.