[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <0e906ec6-fe73-4dbd-b555-a2c03b6e1030@web.de>
Date: Fri, 22 Dec 2023 10:23:13 +0100
From: Markus Elfring <Markus.Elfring@....de>
To: Kuan-Wei Chiu <visitorckw@...il.com>, Abel Vesa <abelvesa@...nel.org>,
Fabio Estevam <festevam@...il.com>,
Michael Turquette <mturquette@...libre.com>, Peng Fan <peng.fan@....com>,
Sascha Hauer <s.hauer@...gutronix.de>, Shawn Guo <shawnguo@...nel.org>,
Stephen Boyd <sboyd@...nel.org>, kernel@...gutronix.de, linux-imx@....com,
linux-clk@...r.kernel.org, linux-arm-kernel@...ts.infradead.org
Cc: LKML <linux-kernel@...r.kernel.org>, cocci@...ia.fr
Subject: [PATCH] clk: imx: scu: Use common error handling code in
__imx_clk_gpr_scu()
From: Markus Elfring <elfring@...rs.sourceforge.net>
Date: Fri, 22 Dec 2023 10:05:32 +0100
Use another label so that a bit of exception handling can be better reused
at the end of this function.
Signed-off-by: Markus Elfring <elfring@...rs.sourceforge.net>
---
drivers/clk/imx/clk-scu.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/drivers/clk/imx/clk-scu.c b/drivers/clk/imx/clk-scu.c
index e48a904c0013..4ca9dccf3d3b 100644
--- a/drivers/clk/imx/clk-scu.c
+++ b/drivers/clk/imx/clk-scu.c
@@ -882,19 +882,19 @@ struct clk_hw *__imx_clk_gpr_scu(const char *name, const char * const *parent_na
return ERR_PTR(-ENOMEM);
if (!imx_scu_clk_is_valid(rsrc_id)) {
- kfree(clk_node);
- return ERR_PTR(-EINVAL);
+ ret = -EINVAL;
+ goto free_clk_node;
}
if (!imx_clk_is_resource_owned(rsrc_id)) {
- kfree(clk_node);
- return NULL;
+ ret = 0;
+ goto free_clk_node;
}
clk = kzalloc(sizeof(*clk), GFP_KERNEL);
if (!clk) {
- kfree(clk_node);
- return ERR_PTR(-ENOMEM);
+ ret = -ENOMEM;
+ goto free_clk_node;
}
clk->rsrc_id = rsrc_id;
@@ -922,6 +922,7 @@ struct clk_hw *__imx_clk_gpr_scu(const char *name, const char * const *parent_na
ret = clk_hw_register(NULL, hw);
if (ret) {
kfree(clk);
+free_clk_node:
kfree(clk_node);
hw = ERR_PTR(ret);
} else {
--
2.43.0
Powered by blists - more mailing lists