Skip to content

Commit

Permalink
regulator: Fix possible nullpointer dereference in regulator_enable()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Heiko Stübner authored and Mark Brown committed Oct 14, 2011
1 parent d162b3c commit d1685e4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/regulator/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1425,7 +1425,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;
Expand Down

0 comments on commit d1685e4

Please sign in to comment.