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]
Date:	Mon, 23 Dec 2013 12:44:40 -0200
From:	Fabio Estevam <festevam@...il.com>
To:	broonie@...nel.org
Cc:	shawn.guo@...aro.org, Anson.Huang@...escale.com,
	linux-kernel@...r.kernel.org,
	Fabio Estevam <fabio.estevam@...escale.com>
Subject: [PATCH v3 1/2] regulator: anatop-regulator: Fix the error handling on probe

From: Fabio Estevam <fabio.estevam@...escale.com>

Currently when of_get_parent() or syscon_node_to_regmap() fail 
'kfree(sreg->name)' is not called, which is incorrect.

Fix this by jumping to 'anatop_probe_end' instead.

While at it, make 'anatop_probe_end' to be executed only on the error path, so
that the code can be a bit easier to follow.

Signed-off-by: Fabio Estevam <fabio.estevam@...escale.com>
---
Changes since v2:
- Fix the error path for of_get_parent() or syscon_node_to_regmap().

 drivers/regulator/anatop-regulator.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/drivers/regulator/anatop-regulator.c b/drivers/regulator/anatop-regulator.c
index c734d09..88d95cd 100644
--- a/drivers/regulator/anatop-regulator.c
+++ b/drivers/regulator/anatop-regulator.c
@@ -132,12 +132,16 @@ static int anatop_regulator_probe(struct platform_device *pdev)
 	rdesc->owner = THIS_MODULE;
 
 	anatop_np = of_get_parent(np);
-	if (!anatop_np)
-		return -ENODEV;
+	if (!anatop_np) {
+		ret = -ENODEV;
+		goto anatop_probe_end;
+	}
 	sreg->anatop = syscon_node_to_regmap(anatop_np);
 	of_node_put(anatop_np);
-	if (IS_ERR(sreg->anatop))
-		return PTR_ERR(sreg->anatop);
+	if (IS_ERR(sreg->anatop)) {
+		ret = PTR_ERR(sreg->anatop);
+		goto anatop_probe_end;
+	}
 
 	ret = of_property_read_u32(np, "anatop-reg-offset",
 				   &sreg->control_reg);
@@ -210,9 +214,10 @@ static int anatop_regulator_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, rdev);
 
+	return 0;
+
 anatop_probe_end:
-	if (ret)
-		kfree(sreg->name);
+	kfree(sreg->name);
 
 	return ret;
 }
-- 
1.8.1.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ