[<prev] [next>] [day] [month] [year] [list]
Message-Id: <dfa8886d700395249851f237ee0b783063168ec7.1661422054.git.christophe.jaillet@wanadoo.fr>
Date: Thu, 25 Aug 2022 12:08:24 +0200
From: Christophe JAILLET <christophe.jaillet@...adoo.fr>
To: Michael Turquette <mturquette@...libre.com>,
Stephen Boyd <sboyd@...nel.org>,
Mike Turquette <mturquette@...aro.org>,
Gabriel FERNANDEZ <gabriel.fernandez@...com>,
Pankaj Dev <pankaj.dev@...com>
Cc: linux-kernel@...r.kernel.org, kernel-janitors@...r.kernel.org,
Christophe JAILLET <christophe.jaillet@...adoo.fr>,
linux-clk@...r.kernel.org
Subject: [PATCH] clk: st: Fix some error handling path in st_of_quadfs_setup()
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@...adoo.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
Powered by blists - more mailing lists