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


Groups > linux.kernel > #1676405 > unrolled thread

[PATCH] clocksource: timer-imx-gpt: Free and unmap region obtained by kzalloc/of_iomap.

Started byArvind Yadav <arvind.yadav.cs@gmail.com>
First post2017-06-28 08:20 +0200
Last post2017-06-28 08:20 +0200
Articles 1 — 1 participant

Back to article view | Back to linux.kernel


Contents

  [PATCH] clocksource: timer-imx-gpt: Free and unmap region obtained by kzalloc/of_iomap. Arvind Yadav <arvind.yadav.cs@gmail.com> - 2017-06-28 08:20 +0200

#1676405 — [PATCH] clocksource: timer-imx-gpt: Free and unmap region obtained by kzalloc/of_iomap.

FromArvind Yadav <arvind.yadav.cs@gmail.com>
Date2017-06-28 08:20 +0200
Subject[PATCH] clocksource: timer-imx-gpt: Free and unmap region obtained by kzalloc/of_iomap.
Message-ID<tXeut-3dj-5@gated-at.bofh.it>
In case of error at init time, rollback iomapping and kfree.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
---
 drivers/clocksource/timer-imx-gpt.c | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/drivers/clocksource/timer-imx-gpt.c b/drivers/clocksource/timer-imx-gpt.c
index f595460..1a8786c 100644
--- a/drivers/clocksource/timer-imx-gpt.c
+++ b/drivers/clocksource/timer-imx-gpt.c
@@ -489,12 +489,16 @@ static int __init mxc_timer_init_dt(struct device_node *np,  enum imx_gpt_type t
 		return -ENOMEM;
 
 	imxtm->base = of_iomap(np, 0);
-	if (!imxtm->base)
-		return -ENXIO;
+	if (!imxtm->base) {
+		ret = -ENXIO;
+		goto error;
+	}
 
 	imxtm->irq = irq_of_parse_and_map(np, 0);
-	if (imxtm->irq <= 0)
-		return -EINVAL;
+	if (imxtm->irq <= 0) {
+		ret = -EINVAL;
+		goto error_free;
+	}
 
 	imxtm->clk_ipg = of_clk_get_by_name(np, "ipg");
 
@@ -507,11 +511,16 @@ static int __init mxc_timer_init_dt(struct device_node *np,  enum imx_gpt_type t
 
 	ret = _mxc_timer_init(imxtm);
 	if (ret)
-		return ret;
+		goto error_free;
 
 	initialized = 1;
 
 	return 0;
+error_free:
+	iounmap(imxtm->base);
+error:
+	kfree(imxtm);
+	return ret;
 }
 
 static int __init imx1_timer_init_dt(struct device_node *np)
-- 
1.9.1

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web