Commit 78ecc562 authored by Jon Hunter's avatar Jon Hunter Committed by Rafael J. Wysocki

PM / OPP: Fix NULL pointer dereference crash when disabling OPPs

Commit 7d34d56e (PM / OPP: Disable OPPs that aren't supported by
the regulator) causes a crash to happen on Tegra124 Jetson TK1 when
using the DFLL clock source for the CPU.  The DFLL manages the voltage
itself and so there is no regulator specified for the OPPs and so we
get a crash when we try to dereference the regulator pointer.  Fix
this by checking to see if the regulator IS_ERR_OR_NULL before
dereferencing it.

Fixes: 7d34d56e (PM / OPP: Disable OPPs that aren't supported by the regulator)
Signed-off-by: default avatarJon Hunter <jonathanh@nvidia.com>
Reported-by: default avatarBartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Acked-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
[ rjw: Changelog ]
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 6a0712f6
...@@ -975,7 +975,7 @@ static bool _opp_supported_by_regulators(struct dev_pm_opp *opp, ...@@ -975,7 +975,7 @@ static bool _opp_supported_by_regulators(struct dev_pm_opp *opp,
{ {
struct regulator *reg = dev_opp->regulator; struct regulator *reg = dev_opp->regulator;
if (!IS_ERR(reg) && if (!IS_ERR_OR_NULL(reg) &&
!regulator_is_supported_voltage(reg, opp->u_volt_min, !regulator_is_supported_voltage(reg, opp->u_volt_min,
opp->u_volt_max)) { opp->u_volt_max)) {
pr_warn("%s: OPP minuV: %lu maxuV: %lu, not supported by regulator\n", pr_warn("%s: OPP minuV: %lu maxuV: %lu, not supported by regulator\n",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment