summaryrefslogtreecommitdiff
path: root/drivers/regulator/core.c
diff options
context:
space:
mode:
authorHeiko Stübner <heiko@sntech.de>2011-10-14 18:00:29 +0200
committerVarun Colbert <vcolbert@nvidia.com>2012-01-20 13:56:35 -0800
commit937ed7672266b64988a86fdf30556f6fe75034da (patch)
tree0ea93e495c6ee1e41778842362a400ebb2a36982 /drivers/regulator/core.c
parenteef4003302ce0dea6ed93480c42abf5b45a3e2e0 (diff)
regulator: Fix possible nullpointer dereference in regulator_enable()
In the case where _regulator_enable returns an error it was not checked if a supplying regulator exists before trying to disable it, leading to a null pointer-dereference if no supplying regulator existed. Signed-off-by: Heiko Stuebner <heiko@sntech.de> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Cherry-pick from main stream: commit d1685e4e2c3854782272f32b71f2f3eff5c6e0d0 Change-Id: Ie4d8db9184a65e6a98964259299bfc7daa0f4048 Reviewed-on: http://git-master/r/75908 Reviewed-by: Pavan Kunapuli <pkunapuli@nvidia.com> Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com> Signed-off-by: Varun Wadekar <vwadekar@nvidia.com> Reviewed-on: http://git-master/r/76462 Reviewed-by: Automatic_Commit_Validation_User
Diffstat (limited to 'drivers/regulator/core.c')
-rw-r--r--drivers/regulator/core.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 79d670c913e2..1b7d64118e4d 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1432,7 +1432,7 @@ int regulator_enable(struct regulator *regulator)
ret = _regulator_enable(rdev);
mutex_unlock(&rdev->mutex);
- if (ret != 0)
+ if (ret != 0 && rdev->supply)
regulator_disable(rdev->supply);
return ret;