[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20201109180920.43193-1-gengdongjiu@huawei.com>
Date: Mon, 9 Nov 2020 18:09:20 +0000
From: Dongjiu Geng <gengdongjiu@...wei.com>
To: <mturquette@...libre.com>, <sboyd@...nel.org>,
<linux-clk@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<gengdongjiu@...wei.com>
Subject: [PATCH V2] clk: hisilicon: Free clk_data and unmap region obtained by of_iomap
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@...wei.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
Powered by blists - more mailing lists