[PATCH 4.4 114/163] regulator: core: Ensure we lock all regulators

From: Greg Kroah-Hartman
Date: Mon May 02 2016 - 21:36:12 EST


4.4-stable review patch. If anyone has any objections, please let me know.

------------------

From: Mark Brown <broonie@xxxxxxxxxx>

commit 49a6bb7a1c0963f260e4b0dcc2c0e56ec65a28b2 upstream.

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@xxxxxxxxxx>
Signed-off-by: Mark Brown <broonie@xxxxxxxxxx>
Cc: Guenter Roeck <linux@xxxxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>

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

--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -141,7 +141,7 @@ static void regulator_lock_supply(struct
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);
}