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-prev] [day] [month] [year] [list]
Date:   Thu, 2 Nov 2017 08:59:31 +0100
From:   SF Markus Elfring <elfring@...rs.sourceforge.net>
To:     kernel-janitors@...r.kernel.org,
        Liam Girdwood <lgirdwood@...il.com>,
        Mark Brown <broonie@...nel.org>
Cc:     LKML <linux-kernel@...r.kernel.org>
Subject: [PATCH 1/3] regulator/core: Use common error handling code in
 regulator_resolve_supply()

From: Markus Elfring <elfring@...rs.sourceforge.net>
Date: Wed, 1 Nov 2017 22:20:13 +0100

* Add a jump target so that a bit of exception handling can be better
  reused at the end of this function.

* Adjust two condition checks.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@...rs.sourceforge.net>
---
 drivers/regulator/core.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index b64b7916507f..14fdf2f17a62 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1554,23 +1554,19 @@ static int regulator_resolve_supply(struct regulator_dev *rdev)
 	 */
 	if (r->dev.parent && r->dev.parent != rdev->dev.parent) {
 		if (!device_is_bound(r->dev.parent)) {
-			put_device(&r->dev);
-			return -EPROBE_DEFER;
+			ret = -EPROBE_DEFER;
+			goto put_device;
 		}
 	}
 
 	/* Recursively resolve the supply of the supply */
 	ret = regulator_resolve_supply(r);
-	if (ret < 0) {
-		put_device(&r->dev);
-		return ret;
-	}
+	if (ret)
+		goto put_device;
 
 	ret = set_supply(rdev, r);
-	if (ret < 0) {
-		put_device(&r->dev);
-		return ret;
-	}
+	if (ret)
+		goto put_device;
 
 	/* Cascade always-on state to supply */
 	if (_regulator_is_enabled(rdev)) {
@@ -1583,6 +1579,10 @@ static int regulator_resolve_supply(struct regulator_dev *rdev)
 	}
 
 	return 0;
+
+put_device:
+	put_device(&r->dev);
+	return ret;
 }
 
 /* Internal regulator request function */
-- 
2.14.3

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ