From: Sudip Mukherjee Date: Wed, 2 Sep 2015 10:44:06 +0000 (+0530) Subject: regulator: core: fix possible NULL dereference X-Git-Tag: next-20150925~37^2~4^2~1 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=9f8df6adf6c53abfa10e243cb289c34eb18ec581;p=uclinux-h8%2Flinux.git regulator: core: fix possible NULL dereference 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 Signed-off-by: Mark Brown --- diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index de9f272a0faf..7150ff6ef46b 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -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; } }