clk: imx8mm: Unregister clks when of_clk_add_provider failed
authorAnson Huang <Anson.Huang@nxp.com>
Tue, 6 Aug 2019 06:46:13 +0000 (14:46 +0800)
committerShawn Guo <shawnguo@kernel.org>
Mon, 12 Aug 2019 14:15:31 +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-imx8mm.c

index 94a2b2941e3b5d466bf156eab1272e75cb6ad49a..69ec274d4974f2d4a757ae192c53895ec0f779d7 100644 (file)
@@ -659,12 +659,17 @@ static int imx8mm_clocks_probe(struct platform_device *pdev)
        ret = of_clk_add_provider(np, of_clk_src_onecell_get, &clk_data);
        if (ret < 0) {
                pr_err("failed to register clks for i.MX8MM\n");
-               return -EINVAL;
+               goto unregister_clks;
        }
 
        imx_register_uart_clocks(uart_clks);
 
        return 0;
+
+unregister_clks:
+       imx_unregister_clocks(clks, ARRAY_SIZE(clks));
+
+       return ret;
 }
 
 static const struct of_device_id imx8mm_clk_of_match[] = {