提交 9f8df6ad 编写于 作者: S Sudip Mukherjee 提交者: Mark Brown

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: NSudip Mukherjee <sudip@vectorindia.org>
Signed-off-by: NMark Brown <broonie@kernel.org>
上级 f5164b88
...@@ -1422,11 +1422,10 @@ static int regulator_resolve_supply(struct regulator_dev *rdev) ...@@ -1422,11 +1422,10 @@ static int regulator_resolve_supply(struct regulator_dev *rdev)
return ret; return ret;
/* Cascade always-on state to supply */ /* Cascade always-on state to supply */
if (_regulator_is_enabled(rdev)) { if (_regulator_is_enabled(rdev) && rdev->supply) {
ret = regulator_enable(rdev->supply); ret = regulator_enable(rdev->supply);
if (ret < 0) { if (ret < 0) {
if (rdev->supply) _regulator_put(rdev->supply);
_regulator_put(rdev->supply);
return ret; return ret;
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册