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:	Fri, 22 Apr 2016 16:33:51 +0200
From:	John Ogness <john.ogness@...utronix.de>
To:	Mark Brown <broonie@...nel.org>
Cc:	linux-kernel@...r.kernel.org
Subject: [PATCH] regulator: core: grab supply info before unlocking

It is necessary to check if there is a supply while still holding
the regulator lock. Otherwise a theoretical race can occur that
someone else can add a supply and then we incorrectly try to
unlock that newly added regulator.

Signed-off-by: John Ogness <john.ogness@...utronix.de>
---
 patch against next-20160421

 drivers/regulator/core.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 9348c78..629f92f 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -161,10 +161,10 @@ static void regulator_unlock_supply(struct regulator_dev *rdev)
 	struct regulator *supply;
 
 	while (1) {
-		mutex_unlock(&rdev->mutex);
 		supply = rdev->supply;
+		mutex_unlock(&rdev->mutex);
 
-		if (!rdev->supply)
+		if (!supply)
 			return;
 
 		rdev = supply->rdev;
-- 
1.7.10.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ