linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] clk: st: Fix some error handling path in st_of_quadfs_setup()
@ 2022-08-25 10:08 Christophe JAILLET
  0 siblings, 0 replies; only message in thread
From: Christophe JAILLET @ 2022-08-25 10:08 UTC (permalink / raw)
  To: Michael Turquette, Stephen Boyd, Mike Turquette,
	Gabriel FERNANDEZ, Pankaj Dev
  Cc: linux-kernel, kernel-janitors, Christophe JAILLET, linux-clk

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@wanadoo.fr>
---
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


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2022-08-25 10:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-25 10:08 [PATCH] clk: st: Fix some error handling path in st_of_quadfs_setup() Christophe JAILLET

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).