linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] regulator: core: Ensure we lock all regulators
@ 2015-12-01 16:40 Mark Brown
  2015-12-01 16:45 ` Arnd Bergmann
  2015-12-02 20:10 ` Applied "regulator: core: Ensure we lock all regulators" to the regulator tree Mark Brown
  0 siblings, 2 replies; 6+ messages in thread
From: Mark Brown @ 2015-12-01 16:40 UTC (permalink / raw)
  To: Thierry Reding, Arnd Bergmann; +Cc: linux-kernel, Tyler Baker, Mark Brown

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.

Reported-by: Tyler Baker <tyler.baker@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
---

Not tested yet.

 drivers/regulator/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index daffff83ced2..f71db02fcb71 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -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);
 }
 
-- 
2.6.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] regulator: core: Ensure we lock all regulators
  2015-12-01 16:40 [PATCH] regulator: core: Ensure we lock all regulators Mark Brown
@ 2015-12-01 16:45 ` Arnd Bergmann
  2015-12-01 16:53   ` Mark Brown
  2015-12-02 20:10 ` Applied "regulator: core: Ensure we lock all regulators" to the regulator tree Mark Brown
  1 sibling, 1 reply; 6+ messages in thread
From: Arnd Bergmann @ 2015-12-01 16:45 UTC (permalink / raw)
  To: Mark Brown; +Cc: Thierry Reding, linux-kernel, Tyler Baker

On Tuesday 01 December 2015 16:40:57 Mark Brown wrote:
> diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
> index daffff83ced2..f71db02fcb71 100644
> --- a/drivers/regulator/core.c
> +++ b/drivers/regulator/core.c
> @@ -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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] regulator: core: Ensure we lock all regulators
  2015-12-01 16:45 ` Arnd Bergmann
@ 2015-12-01 16:53   ` Mark Brown
  2015-12-01 19:37     ` Arnd Bergmann
  0 siblings, 1 reply; 6+ messages in thread
From: Mark Brown @ 2015-12-01 16:53 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: Thierry Reding, linux-kernel, Tyler Baker

[-- Attachment #1: Type: text/plain, Size: 513 bytes --]

On Tue, Dec 01, 2015 at 05:45:17PM +0100, Arnd Bergmann wrote:
> On Tuesday 01 December 2015 16:40:57 Mark Brown wrote:

> >         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.

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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] regulator: core: Ensure we lock all regulators
  2015-12-01 16:53   ` Mark Brown
@ 2015-12-01 19:37     ` Arnd Bergmann
  2015-12-01 19:42       ` Mark Brown
  0 siblings, 1 reply; 6+ messages in thread
From: Arnd Bergmann @ 2015-12-01 19:37 UTC (permalink / raw)
  To: Mark Brown; +Cc: Thierry Reding, linux-kernel, Tyler Baker

On Tuesday 01 December 2015 16:53:01 Mark Brown wrote:
> On Tue, Dec 01, 2015 at 05:45:17PM +0100, Arnd Bergmann wrote:
> > On Tuesday 01 December 2015 16:40:57 Mark Brown wrote:
> 
> > >         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.
> 
> 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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] regulator: core: Ensure we lock all regulators
  2015-12-01 19:37     ` Arnd Bergmann
@ 2015-12-01 19:42       ` Mark Brown
  0 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2015-12-01 19:42 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: Thierry Reding, linux-kernel, Tyler Baker

[-- Attachment #1: Type: text/plain, Size: 458 bytes --]

On Tue, Dec 01, 2015 at 08:37:35PM +0100, Arnd Bergmann wrote:
> 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 :)

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Applied "regulator: core: Ensure we lock all regulators" to the regulator tree
  2015-12-01 16:40 [PATCH] regulator: core: Ensure we lock all regulators Mark Brown
  2015-12-01 16:45 ` Arnd Bergmann
@ 2015-12-02 20:10 ` Mark Brown
  1 sibling, 0 replies; 6+ messages in thread
From: Mark Brown @ 2015-12-02 20:10 UTC (permalink / raw)
  To: Tyler Baker, Mark Brown; +Cc: linux-kernel

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

>From 49a6bb7a1c0963f260e4b0dcc2c0e56ec65a28b2 Mon Sep 17 00:00:00 2001
From: Mark Brown <broonie@kernel.org>
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.

Reported-by: Tyler Baker <tyler.baker@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 drivers/regulator/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index daffff83ced2..f71db02fcb71 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -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);
 }
 
-- 
2.6.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-12-02 20:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-01 16:40 [PATCH] regulator: core: Ensure we lock all regulators Mark Brown
2015-12-01 16:45 ` Arnd Bergmann
2015-12-01 16:53   ` Mark Brown
2015-12-01 19:37     ` Arnd Bergmann
2015-12-01 19:42       ` Mark Brown
2015-12-02 20:10 ` Applied "regulator: core: Ensure we lock all regulators" to the regulator tree Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).