aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Hunter <jonathanh@nvidia.com>2016-04-21 12:11:58 -0400
committerMark Brown <broonie@kernel.org>2016-04-22 06:35:54 -0400
commit8e5356a73604f53da6a1e0756727cb8f9f7bba17 (patch)
tree01416c461a8b1d55b19ddff861bcb7af849738f4
parent7ddede6a58a0bd26efcfd2a5055611195411f514 (diff)
regulator: core: Clear the supply pointer if enabling fails
During the resolution of a regulator's supply, we may attempt to enable the supply if the regulator itself is already enabled. If enabling the supply fails, then we will call _regulator_put() for the supply. However, the pointer to the supply has not been cleared for the regulator and this will cause a crash if we then unregister the regulator and attempt to call regulator_put() a second time for the supply. Fix this by clearing the supply pointer if enabling the supply after fails when resolving the supply for a regulator. Signed-off-by: Jon Hunter <jonathanh@nvidia.com> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--drivers/regulator/core.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 9922922ce6bd..bd9ec309b707 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1536,6 +1536,7 @@ static int regulator_resolve_supply(struct regulator_dev *rdev)
1536 ret = regulator_enable(rdev->supply); 1536 ret = regulator_enable(rdev->supply);
1537 if (ret < 0) { 1537 if (ret < 0) {
1538 _regulator_put(rdev->supply); 1538 _regulator_put(rdev->supply);
1539 rdev->supply = NULL;
1539 return ret; 1540 return ret;
1540 } 1541 }
1541 } 1542 }