[PATCH] clk: st: Fix some error handling path in st_of_quadfs_setup()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If an error occurs, some resources still need to be released.

Add the corresponding error handing path.

Fixes: 5f7aa9071e93 ("clk: st: Support for QUADFS inside ClockGenB/C/D/E/F")
Signed-off-by: Christophe JAILLET <christophe.jaillet@xxxxxxxxxx>
---
This patch is NOT compile tested.
I don't have the needed build tool chain.
---
 drivers/clk/st/clkgen-fsyn.c | 28 +++++++++++++++++-----------
 1 file changed, 17 insertions(+), 11 deletions(-)

diff --git a/drivers/clk/st/clkgen-fsyn.c b/drivers/clk/st/clkgen-fsyn.c
index d820292a381d..d1b3a4162682 100644
--- a/drivers/clk/st/clkgen-fsyn.c
+++ b/drivers/clk/st/clkgen-fsyn.c
@@ -984,7 +984,7 @@ static void __init st_of_quadfs_setup(struct device_node *np,
 		struct clkgen_quadfs_data_clks *datac)
 {
 	struct clk *clk;
-	const char *pll_name, *clk_parent_name;
+	const char *pll_name = NULL, *clk_parent_name;
 	void __iomem *reg;
 	spinlock_t *lock;
 	struct device_node *parent_np;
@@ -1006,32 +1006,38 @@ static void __init st_of_quadfs_setup(struct device_node *np,
 
 	clk_parent_name = of_clk_get_parent_name(np, 0);
 	if (!clk_parent_name)
-		return;
+		goto err_unmap;
 
 	pll_name = kasprintf(GFP_KERNEL, "%pOFn.pll", np);
 	if (!pll_name)
-		return;
+		goto err_unmap;
 
 	lock = kzalloc(sizeof(*lock), GFP_KERNEL);
 	if (!lock)
-		goto err_exit;
+		goto err_unmap;
 
 	spin_lock_init(lock);
 
 	clk = st_clk_register_quadfs_pll(pll_name, clk_parent_name, datac->data,
 			reg, lock);
 	if (IS_ERR(clk))
-		goto err_exit;
-	else
-		pr_debug("%s: parent %s rate %u\n",
-			__clk_get_name(clk),
-			__clk_get_name(clk_get_parent(clk)),
-			(unsigned int)clk_get_rate(clk));
+		goto err_free_lock;
+
+	pr_debug("%s: parent %s rate %u\n",
+		 __clk_get_name(clk), __clk_get_name(clk_get_parent(clk)),
+		 (unsigned int)clk_get_rate(clk));
 
 	st_of_create_quadfs_fsynths(np, pll_name, datac, reg, lock);
 
-err_exit:
+out:
 	kfree(pll_name); /* No longer need local copy of the PLL name */
+	return;
+
+err_free_lock:
+	kfree(lock);
+err_unmap:
+	iounmap(reg);
+	goto out;
 }
 
 static void __init st_of_quadfs660C_setup(struct device_node *np)
-- 
2.34.1




[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux