mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH V2] clk: hisilicon: Free clk_data and unmap region obtained by of_iomap
@ 2020-11-09 18:09 Dongjiu Geng
  2020-11-09 12:02 ` Dongjiu Geng
       [not found] ` <c6d2fe3b-3261-2c0f-f245-49bb5e63c1ed@web.de>
  0 siblings, 2 replies; 3+ messages in thread
From: Dongjiu Geng @ 2020-11-09 18:09 UTC (permalink / raw)
  To: mturquette, sboyd, linux-clk, linux-kernel, gengdongjiu

Free memory mapping and free clk_data, if clock initialization
is not successful.

Fixes: 75af25f581b1 ("clk: hisi: remove static variable")
Fixes: 62ac983b6141 ("clk: hisilicon: add hi3620_mmc_clks")
Signed-off-by: Dongjiu Geng <gengdongjiu@huawei.com>
---
 drivers/clk/hisilicon/clk-hi3620.c |  8 ++++++--
 drivers/clk/hisilicon/clk.c        | 11 ++++++-----
 2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/drivers/clk/hisilicon/clk-hi3620.c b/drivers/clk/hisilicon/clk-hi3620.c
index a3d04c7c3da8..864d2ddfc73c 100644
--- a/drivers/clk/hisilicon/clk-hi3620.c
+++ b/drivers/clk/hisilicon/clk-hi3620.c
@@ -464,11 +464,11 @@ static void __init hi3620_mmc_clk_init(struct device_node *node)
 
 	clk_data = kzalloc(sizeof(*clk_data), GFP_KERNEL);
 	if (WARN_ON(!clk_data))
-		return;
+		goto unmap_io;
 
 	clk_data->clks = kcalloc(num, sizeof(*clk_data->clks), GFP_KERNEL);
 	if (!clk_data->clks)
-		return;
+		goto free_clk_data;
 
 	for (i = 0; i < num; i++) {
 		struct hisi_mmc_clock *mmc_clk = &hi3620_mmc_clks[i];
@@ -478,6 +478,10 @@ static void __init hi3620_mmc_clk_init(struct device_node *node)
 
 	clk_data->clk_num = num;
 	of_clk_add_provider(node, of_clk_src_onecell_get, clk_data);
+free_clk_data:
+	kfree(clk_data);
+unmap_io:
+	iounmap(base);
 }
 
 CLK_OF_DECLARE(hi3620_mmc_clk, "hisilicon,hi3620-mmc-clock", hi3620_mmc_clk_init);
diff --git a/drivers/clk/hisilicon/clk.c b/drivers/clk/hisilicon/clk.c
index 54d9fdc93599..da655683710f 100644
--- a/drivers/clk/hisilicon/clk.c
+++ b/drivers/clk/hisilicon/clk.c
@@ -65,25 +65,26 @@ struct hisi_clock_data *hisi_clk_init(struct device_node *np,
 	base = of_iomap(np, 0);
 	if (!base) {
 		pr_err("%s: failed to map clock registers\n", __func__);
-		goto err;
+		return NULL;
 	}
 
 	clk_data = kzalloc(sizeof(*clk_data), GFP_KERNEL);
 	if (!clk_data)
-		goto err;
+		goto unmap_io;
 
 	clk_data->base = base;
 	clk_table = kcalloc(nr_clks, sizeof(*clk_table), GFP_KERNEL);
 	if (!clk_table)
-		goto err_data;
+		goto free_clk_data;
 
 	clk_data->clk_data.clks = clk_table;
 	clk_data->clk_data.clk_num = nr_clks;
 	of_clk_add_provider(np, of_clk_src_onecell_get, &clk_data->clk_data);
 	return clk_data;
-err_data:
+free_clk_data:
 	kfree(clk_data);
-err:
+unmap_io:
+	iounmap(base);
 	return NULL;
 }
 EXPORT_SYMBOL_GPL(hisi_clk_init);
-- 
2.17.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-11-10 11:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-09 18:09 [PATCH V2] clk: hisilicon: Free clk_data and unmap region obtained by of_iomap Dongjiu Geng
2020-11-09 12:02 ` Dongjiu Geng
     [not found] ` <c6d2fe3b-3261-2c0f-f245-49bb5e63c1ed@web.de>
2020-11-10 11:58   ` [PATCH v2] " Dongjiu Geng

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®