[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <87wpnp90hc.fsf@linutronix.de>
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