clk: imx8mq: Unregister clks when of_clk_add_provider failed
authorAnson Huang <Anson.Huang@nxp.com>
Tue, 6 Aug 2019 06:46:14 +0000 (14:46 +0800)
committerShawn Guo <shawnguo@kernel.org>
Mon, 12 Aug 2019 14:15:49 +0000 (16:15 +0200)
When of_clk_add_provider failed, all clks should be unregistered.

Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
Reviewed-by: Daniel Baluta <daniel.baluta@nxp.com>
Signed-off-by: Shawn Guo <shawnguo@kernel.org>
drivers/clk/imx/clk-imx8mq.c

index 04302f27dd0f8d367db68cef37f8f30b076baab0..81a024928408b5a2683636b317891d9690dae9ec 100644 (file)
@@ -562,10 +562,18 @@ static int imx8mq_clocks_probe(struct platform_device *pdev)
        clk_data.clk_num = ARRAY_SIZE(clks);
 
        err = of_clk_add_provider(np, of_clk_src_onecell_get, &clk_data);
-       WARN_ON(err);
+       if (err < 0) {
+               dev_err(dev, "failed to register clks for i.MX8MQ\n");
+               goto unregister_clks;
+       }
 
        imx_register_uart_clocks(uart_clks);
 
+       return 0;
+
+unregister_clks:
+       imx_unregister_clocks(clks, ARRAY_SIZE(clks));
+
        return err;
 }