Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

clk: scpi: error when clock fails to register

Current implementation of scpi_clk_add just print a warning when clock
fails to register but then keep going as if nothing happened. The
provider is then registered with bogus data.

This may latter lead to an Oops in __clk_create_clk when
hlist_add_head(&clk->clks_node, &hw->core->clks) is called.

This patch fixes the issue and errors if a clock fails to register.

Fixes: cd52c2a4b5c4 ("clk: add support for clocks provided by SCP(System Control Processor)")
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
Reviewed-by: Sudeep Holla <sudeep.holla@arm.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>

authored by

Jerome Brunet and committed by
Stephen Boyd
2b286b09 b3b02eac

+5 -3
+5 -3
drivers/clk/clk-scpi.c
··· 245 245 sclk->id = val; 246 246 247 247 err = scpi_clk_ops_init(dev, match, sclk, name); 248 - if (err) 248 + if (err) { 249 249 dev_err(dev, "failed to register clock '%s'\n", name); 250 - else 251 - dev_dbg(dev, "Registered clock '%s'\n", name); 250 + return err; 251 + } 252 + 253 + dev_dbg(dev, "Registered clock '%s'\n", name); 252 254 clk_data->clk[idx] = sclk; 253 255 } 254 256