Message ID | E1sBrzn-00E8GK-Ue@rmk-PC.armlinux.org.uk (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | clk: clkdev: don't fail clkdev_alloc() if over-sized | expand |
On 5/28/24 1:15 AM, Russell King (Oracle) wrote: > 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. > > 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. > Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> > --- > > Please try this patch, which should allow the platform to boot, bit will > intentionally issue lots of warnings. There is a separate patch posted > recently that removes the useless registration with clkdev. > > drivers/clk/clkdev.c | 11 +++++++++-- > 1 file changed, 9 insertions(+), 2 deletions(-) > > diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c > index 6a77d7e201a9..2f83fb97c6fb 100644 > --- a/drivers/clk/clkdev.c > +++ b/drivers/clk/clkdev.c > @@ -204,8 +204,15 @@ vclkdev_alloc(struct clk_hw *hw, const char *con_id, const char *dev_fmt, > 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 * Works good. Here's what it looks like on HiFive Unmatched. [0.389138] riscv-plic c000000.interrupt-controller: mapped 69 interrupts with 4 handlers for 9 contexts. [0.390710] shpchp: Standard Hot Plug PCI Controller Driver version: 0.4 [0.392743] 10000000.clock-controller:corepll: device ID is greater than 24 [0.392792] 10000000.clock-controller:ddrpll: device ID is greater than 24 [0.392820] 10000000.clock-controller:gemgxlpll: device ID is greater than 24 [0.392847] 10000000.clock-controller:dvfscorepll: device ID is greater than 24 [0.392876] 10000000.clock-controller:hfpclkpll: device ID is greater than 24 [0.392903] 10000000.clock-controller:cltxpll: device ID is greater than 24 [0.392929] 10000000.clock-controller:tlclk: device ID is greater than 24 [0.392955] 10000000.clock-controller:pclk: device ID is greater than 24 [0.392981] 10000000.clock-controller:pcie_aux: device ID is greater than 24 [0.394620] Serial: 8250/16550 driver, 32 ports, IRQ sharing enabled [0.413222] SuperH (H)SCI(F) driver initialized Tested-by: Ron Economos <re@w6rz.net>
diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c index 6a77d7e201a9..2f83fb97c6fb 100644 --- a/drivers/clk/clkdev.c +++ b/drivers/clk/clkdev.c @@ -204,8 +204,15 @@ vclkdev_alloc(struct clk_hw *hw, const char *con_id, const char *dev_fmt, 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 *
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. 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. Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> --- Please try this patch, which should allow the platform to boot, bit will intentionally issue lots of warnings. There is a separate patch posted recently that removes the useless registration with clkdev. drivers/clk/clkdev.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)