clk: scpi: error when clock fails to register
authorJerome Brunet <jbrunet@baylibre.com>
Wed, 28 Jun 2017 13:53:45 +0000 (15:53 +0200)
committerStephen Boyd <sboyd@codeaurora.org>
Fri, 30 Jun 2017 01:47:35 +0000 (18:47 -0700)
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>
drivers/clk/clk-scpi.c

index 8ad458b..2585472 100644 (file)
@@ -245,10 +245,12 @@ static int scpi_clk_add(struct device *dev, struct device_node *np,
                sclk->id = val;
 
                err = scpi_clk_ops_init(dev, match, sclk, name);
-               if (err)
+               if (err) {
                        dev_err(dev, "failed to register clock '%s'\n", name);
-               else
-                       dev_dbg(dev, "Registered clock '%s'\n", name);
+                       return err;
+               }
+
+               dev_dbg(dev, "Registered clock '%s'\n", name);
                clk_data->clk[idx] = sclk;
        }