Skip to content

Commit 616501e

Browse files
author
Russell King (Oracle)
committed
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 <[email protected]> Reported-by: Guenter Roeck <[email protected]> Fixes: 8d53252 ("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]>
1 parent 8d53252 commit 616501e

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

drivers/clk/clkdev.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,15 @@ vclkdev_alloc(struct clk_hw *hw, const char *con_id, const char *dev_fmt,
204204
pr_err("%pV:%s: %s ID is greater than %zu\n",
205205
&vaf, con_id, failure, max_size);
206206
va_end(ap_copy);
207-
kfree(cla);
208-
return NULL;
207+
208+
/*
209+
* Don't fail in this case, but as the entry won't ever match just
210+
* fill it with something that also won't match.
211+
*/
212+
strscpy(cla->con_id, "bad", sizeof(cla->con_id));
213+
strscpy(cla->dev_id, "bad", sizeof(cla->dev_id));
214+
215+
return &cla->cl;
209216
}
210217

211218
static struct clk_lookup *

0 commit comments

Comments
 (0)