Skip to content

Commit

Permalink
regulator: core: fix possible NULL dereference
Browse files Browse the repository at this point in the history
We were checking rdev->supply for NULL after dereferencing it. Lets
check for rdev->supply along with _regulator_is_enabled() and call
regulator_enable() only if rdev->supply is not NULL.

Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
  • Loading branch information
Sudip Mukherjee authored and Mark Brown committed Sep 2, 2015
1 parent f5164b8 commit 9f8df6a
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions drivers/regulator/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1422,11 +1422,10 @@ static int regulator_resolve_supply(struct regulator_dev *rdev)
return ret;

/* Cascade always-on state to supply */
if (_regulator_is_enabled(rdev)) {
if (_regulator_is_enabled(rdev) && rdev->supply) {
ret = regulator_enable(rdev->supply);
if (ret < 0) {
if (rdev->supply)
_regulator_put(rdev->supply);
_regulator_put(rdev->supply);
return ret;
}
}
Expand Down

0 comments on commit 9f8df6a

Please sign in to comment.