Skip to contentSkip to conversation

regulator: core: Ensure we lock all regulators

PATCH In review Mark Brown 2 participants 6 messages Dec 1, 2015 – Dec 2, 2015 Voltage and current regulator framework

lore
Share & tools
lore

Mark Brown

author maintainer
#0 lore raw

PATCH 1/1 regulator: core: Ensure we lock all regulators

The latest workaround for the lockdep interface's not using the second argument of mutex_lock_nested() changed the loop missed locking the last regulator due to a thinko with the loop termination condition exiting one regulator too soon.

---

Not tested yet.

 drivers/regulator/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/regulator/core.c +1 -1
index daffff83ced2..f71db02fcb71 100644
@@ -141,7 +141,7 @@ static void regulator_lock_supply(struct regulator_dev *rdev)
 	int i;
 
 	mutex_lock(&rdev->mutex);
-	for (i = 1; rdev->supply; rdev = rdev->supply->rdev, i++)
+	for (i = 1; rdev; rdev = rdev->supply->rdev, i++)
 		mutex_lock_nested(&rdev->mutex, i);
 }
 
Signature · 1 line
2.6.2
#1 lore raw

drivers/regulator/core.c static void regulator_lock_supply(struct regulator_dev *rdev) · line 146

Quoted 12 lines · On Tuesday 01 December 2015 16:40:57 Mark Brown wrote:
drivers/regulator/core.c +1 -1
index daffff83ced2..f71db02fcb71 100644
@@ -141,7 +141,7 @@ static void regulator_lock_supply(struct regulator_dev *rdev)
        int i;
 
        mutex_lock(&rdev->mutex);
-       for (i = 1; rdev->supply; rdev = rdev->supply->rdev, i++)
+       for (i = 1; rdev; rdev = rdev->supply->rdev, i++)
                mutex_lock_nested(&rdev->mutex, i);
 

I think now we have a double lock, the initial mutex_lock() needs to be removed again.

Arnd

author maintainer
#2 lore raw
Quoted 9 lines · Arnd Bergmann

drivers/regulator/core.c static void regulator_lock_supply(struct regulator_dev *rdev) · line 145

Quoted 4 lines · On Tuesday 01 December 2015 16:40:57 Mark Brown wrote:
        mutex_lock(&rdev->mutex);
drivers/regulator/core.c +1 -1
-       for (i = 1; rdev->supply; rdev = rdev->supply->rdev, i++)
+       for (i = 1; rdev; rdev = rdev->supply->rdev, i++)
                mutex_lock_nested(&rdev->mutex, i);

I think now we have a double lock, the initial mutex_lock() needs to be removed again.

Ugh, I even made that fix before I sent but didn't actually commit it :(

#3 lore raw
Quoted 8 lines · On Tuesday 01 December 2015 16:53:01 Mark Brown wrote:
Quoted 6 lines · Arnd Bergmann
Quoted 4 lines · On Tuesday 01 December 2015 16:40:57 Mark Brown wrote:
        mutex_lock(&rdev->mutex);
drivers/regulator/core.c +1 -1
-       for (i = 1; rdev->supply; rdev = rdev->supply->rdev, i++)
+       for (i = 1; rdev; rdev = rdev->supply->rdev, i++)
                mutex_lock_nested(&rdev->mutex, i);
Quoted 5 lines
Quoted 2 lines

I think now we have a double lock, the initial mutex_lock() needs to be removed again.

Ugh, I even made that fix before I sent but didn't actually commit it

I'm glad I'm not the only one who can screw up a trivial one-line fix to this damned function. ;-)

I'm still leading with three stupid mistakes over your one though.

Arnd

author maintainer
#4 lore raw
Quoted 8 lines · Arnd Bergmann
Quoted 1 line · On Tuesday 01 December 2015 16:53:01 Mark Brown wrote:

Ugh, I even made that fix before I sent but didn't actually commit it

I'm glad I'm not the only one who can screw up a trivial one-line fix to this damned function. ;-)

I'm still leading with three stupid mistakes over your one though.

I blame the -next builds that my machine is toiling under making me skimp on testing :)

author maintainer
#5 lore raw

Applied "regulator: core: Ensure we lock all regulators" to the regulator tree

In reply to Mark Brown

The patch

regulator: core: Ensure we lock all regulators

has been applied to the regulator tree at

git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

Quoted 1 line

From 49a6bb7a1c0963f260e4b0dcc2c0e56ec65a28b2 Mon Sep 17 00:00:00 2001

From: Mark Brown <[email protected]>
Date: Tue, 1 Dec 2015 15:51:52 +0000
Subject: [PATCH] regulator: core: Ensure we lock all regulators

The latest workaround for the lockdep interface's not using the second argument of mutex_lock_nested() changed the loop missed locking the last regulator due to a thinko with the loop termination condition exiting one regulator too soon.

---
 drivers/regulator/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/regulator/core.c +1 -1
index daffff83ced2..f71db02fcb71 100644
@@ -141,7 +141,7 @@ static void regulator_lock_supply(struct regulator_dev *rdev)
 	int i;
 
 	mutex_lock(&rdev->mutex);
-	for (i = 1; rdev->supply; rdev = rdev->supply->rdev, i++)
+	for (i = 1; rdev; rdev = rdev->supply->rdev, i++)
 		mutex_lock_nested(&rdev->mutex, i);
 }
 
Signature · 1 line
2.6.2