Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1487299

[PATCH] clk: renesas: clk-mstp: Free memory and Unmap region obtained by kzalloc and of_iomap

From Arvind Yadav <arvind.yadav.cs@gmail.com>
Newsgroups linux.kernel
Subject [PATCH] clk: renesas: clk-mstp: Free memory and Unmap region obtained by kzalloc and of_iomap
Date 2016-09-20 14:50 +0200
Message-ID <sjsEO-31h-19@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


From: Arvind Yadav <arvind.yadav.cs@gmail.com>

Free memory and memory mapping , if cpg_mstp_clocks_init is not successful.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
---
 drivers/clk/renesas/clk-mstp.c |   14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/renesas/clk-mstp.c b/drivers/clk/renesas/clk-mstp.c
index 5093a25..19e73c8 100644
--- a/drivers/clk/renesas/clk-mstp.c
+++ b/drivers/clk/renesas/clk-mstp.c
@@ -179,14 +179,20 @@ static void __init cpg_mstp_clocks_init(struct device_node *np)
 	group->data.clks = clks;
 
 	group->smstpcr = of_iomap(np, 0);
-	group->mstpsr = of_iomap(np, 1);
-
 	if (group->smstpcr == NULL) {
 		pr_err("%s: failed to remap SMSTPCR\n", __func__);
 		kfree(group);
 		kfree(clks);
 		return;
 	}
+	group->mstpsr = of_iomap(np, 1);
+	if (group->mstpsr == NULL) {
+		pr_err("%s: failed to remap MSTPCR\n", __func__);
+		iounmap(group->smstpcr);
+		kfree(group);
+		kfree(clks);
+		return;
+	}
 
 	for (i = 0; i < MSTP_MAX_CLOCKS; ++i)
 		clks[i] = ERR_PTR(-ENOENT);
@@ -236,6 +242,10 @@ static void __init cpg_mstp_clocks_init(struct device_node *np)
 		} else {
 			pr_err("%s: failed to register %s %s clock (%ld)\n",
 			       __func__, np->name, name, PTR_ERR(clks[clkidx]));
+			iounmap(group->smstpcr);
+			iounmap(group->mstpsr);
+			kfree(group);
+			kfree(clks);
 		}
 	}
 
-- 
1.7.9.5

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH] clk: renesas: clk-mstp: Free memory and Unmap region obtained by kzalloc and of_iomap Arvind Yadav <arvind.yadav.cs@gmail.com> - 2016-09-20 14:50 +0200
  Re: [PATCH] clk: renesas: clk-mstp: Free memory and Unmap region obtained by kzalloc and of_iomap Laurent Pinchart <laurent.pinchart@ideasonboard.com> - 2016-09-20 14:50 +0200

csiph-web