linux-clk.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch] clk: meson: add some error handling in meson_clk_register_cpu()
@ 2015-06-11 15:20 Dan Carpenter
  2015-06-11 15:26 ` Carlo Caione
  2015-06-11 23:13 ` Stephen Boyd
  0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2015-06-11 15:20 UTC (permalink / raw)
  To: Mike Turquette; +Cc: Stephen Boyd, Carlo Caione, linux-clk, kernel-janitors

This error handling hopefully isn't needed but it make the static
checkers happy.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/drivers/clk/meson/clk-cpu.c b/drivers/clk/meson/clk-cpu.c
index 148e99f..71ad493 100644
--- a/drivers/clk/meson/clk-cpu.c
+++ b/drivers/clk/meson/clk-cpu.c
@@ -213,22 +213,30 @@ struct clk *meson_clk_register_cpu(const struct clk_conf *clk_conf,
 	if (!pclk) {
 		pr_err("%s: could not lookup parent clock %s\n",
 				__func__, clk_conf->clks_parent[0]);
-		return ERR_PTR(-EINVAL);
+		ret = -EINVAL;
+		goto free_clk;
 	}
 
 	ret = clk_notifier_register(pclk, &clk_cpu->clk_nb);
 	if (ret) {
 		pr_err("%s: failed to register clock notifier for %s\n",
 				__func__, clk_conf->clk_name);
-		return ERR_PTR(-EINVAL);
+		goto free_clk;
 	}
 
 	clk = clk_register(NULL, &clk_cpu->hw);
 	if (IS_ERR(clk)) {
-		clk_notifier_unregister(pclk, &clk_cpu->clk_nb);
-		kfree(clk_cpu);
+		ret = PTR_ERR(clk);
+		goto unregister_clk_nb;
 	}
 
 	return clk;
+
+unregister_clk_nb:
+	clk_notifier_unregister(pclk, &clk_cpu->clk_nb);
+free_clk:
+	kfree(clk_cpu);
+
+	return ERR_PTR(ret);
 }
 

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-06-11 23:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-11 15:20 [patch] clk: meson: add some error handling in meson_clk_register_cpu() Dan Carpenter
2015-06-11 15:26 ` Carlo Caione
2015-06-11 23:13 ` Stephen Boyd

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).