Skip to content

Commit

Permalink
regulator: core: Clear the supply pointer if enabling fails
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jon Hunter authored and Mark Brown committed Apr 22, 2016
1 parent 7ddede6 commit 8e5356a
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions drivers/regulator/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1536,6 +1536,7 @@ static int regulator_resolve_supply(struct regulator_dev *rdev)
ret = regulator_enable(rdev->supply);
if (ret < 0) {
_regulator_put(rdev->supply);
rdev->supply = NULL;
return ret;
}
}
Expand Down

0 comments on commit 8e5356a

Please sign in to comment.