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>] [day] [month] [year] [list]
Message-Id: <a721f848ac11942676420b14563e6b9f8bca3c48.1498646296.git.arvind.yadav.cs@gmail.com>
Date:   Wed, 28 Jun 2017 16:08:42 +0530
From:   Arvind Yadav <arvind.yadav.cs@...il.com>
To:     daniel.lezcano@...aro.org, tglx@...utronix.de
Cc:     linux-kernel@...r.kernel.org
Subject: [PATCH] clocksource: timer-digicolor:  Fix resource leaks in error paths.

Handle return value of clk_prepare_enable. In case of error at init time,
rollback iomapping and unprepare clk.

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

diff --git a/drivers/clocksource/timer-integrator-ap.c b/drivers/clocksource/timer-integrator-ap.c
index 04ad306..27de3f5 100644
--- a/drivers/clocksource/timer-integrator-ap.c
+++ b/drivers/clocksource/timer-integrator-ap.c
@@ -183,6 +183,7 @@ static int __init integrator_ap_timer_init_of(struct device_node *node)
 	unsigned long rate;
 	struct device_node *pri_node;
 	struct device_node *sec_node;
+	struct resource res;
 
 	base = of_io_request_and_map(node, 0, "integrator-timer");
 	if (IS_ERR(base))
@@ -191,9 +192,13 @@ static int __init integrator_ap_timer_init_of(struct device_node *node)
 	clk = of_clk_get(node, 0);
 	if (IS_ERR(clk)) {
 		pr_err("No clock for %s\n", node->name);
-		return PTR_ERR(clk);
+		err = PTR_ERR(clk);
+		goto err_mem;
 	}
-	clk_prepare_enable(clk);
+	err = clk_prepare_enable(clk);
+	if (err)
+		goto err_clk_put;
+
 	rate = clk_get_rate(clk);
 	writel(0, base + TIMER_CTRL);
 
@@ -201,7 +206,7 @@ static int __init integrator_ap_timer_init_of(struct device_node *node)
 				"arm,timer-primary", &path);
 	if (err) {
 		pr_warn("Failed to read property\n");
-		return err;
+		goto err_clk_disable;
 	}
 
 	pri_node = of_find_node_by_path(path);
@@ -210,7 +215,7 @@ static int __init integrator_ap_timer_init_of(struct device_node *node)
 				"arm,timer-secondary", &path);
 	if (err) {
 		pr_warn("Failed to read property\n");
-		return err;
+		goto err_clk_disable;
 	}
 
 
@@ -230,6 +235,16 @@ static int __init integrator_ap_timer_init_of(struct device_node *node)
 	clk_disable_unprepare(clk);
 
 	return 0;
+
+err_clk_disable:
+	clk_disable_unprepare(clk);
+err_clk_put:
+	clk_put(clk);
+err_mem:
+	iounmap(base);
+	of_address_to_resource(node, 0, &res);
+	release_mem_region(res.start, resource_size(&res));
+	return err;
 }
 
 CLOCKSOURCE_OF_DECLARE(integrator_ap_timer, "arm,integrator-timer",
-- 
1.9.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ