lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1474631874-5777-1-git-send-email-arvind.yadav.cs@gmail.com>
Date:   Fri, 23 Sep 2016 17:27:54 +0530
From:   Arvind Yadav <arvind.yadav.cs@...il.com>
To:     baohua@...nel.org, daniel.lezcano@...aro.org, tglx@...utronix.de
Cc:     linux-kernel@...r.kernel.org
Subject: [PATCH V3] clocksource/timer-imx-gpt: Preventing resource leakage in error case.

-Free previously allocated memory.
-Unmap I/O memory from kernel address space.

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

diff --git a/drivers/clocksource/timer-imx-gpt.c b/drivers/clocksource/timer-imx-gpt.c
index f595460..31cfccf 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_free;
+	}
 
 	imxtm->irq = irq_of_parse_and_map(np, 0);
-	if (imxtm->irq <= 0)
-		return -EINVAL;
+	if (imxtm->irq <= 0) {
+		ret = -EINVAL;
+		goto error_iounmap;
+	}
 
 	imxtm->clk_ipg = of_clk_get_by_name(np, "ipg");
 
@@ -506,12 +510,19 @@ static int __init mxc_timer_init_dt(struct device_node *np,  enum imx_gpt_type t
 	imxtm->type = type;
 
 	ret = _mxc_timer_init(imxtm);
-	if (ret)
-		return ret;
+	if (ret) {
+		goto error_iounmap;
+	}
 
 	initialized = 1;
 
 	return 0;
+
+error_iounmap:
+	iounmap(imxtm->base);
+error_kfree:
+	kfree(imxtm);
+	return ret;
 }
 
 static int __init imx1_timer_init_dt(struct device_node *np)
-- 
2.7.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ