PM / OPP: Fix NULL pointer dereference crash when disabling OPPs
authorJon Hunter <jonathanh@nvidia.com>
Thu, 11 Feb 2016 11:25:59 +0000 (11:25 +0000)
committerAlex Shi <alex.shi@linaro.org>
Fri, 8 Apr 2016 03:24:28 +0000 (11:24 +0800)
commited343155489aa67740862d959e71266992ddf1b5
tree2761339e9bc0776cfa4e5525db342efba58ef844
parent6229dc0db2699e56996cb114a85eb59988e1163a
PM / OPP: Fix NULL pointer dereference crash when disabling OPPs

Commit 7d34d56ef334 (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: 7d34d56ef334 (PM / OPP: Disable OPPs that aren't supported by the regulator)
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reported-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
[ rjw: Changelog ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
(cherry picked from commit 78ecc56247f0ec2bc0cf6f2f2af69e98d99767bc)
Signed-off-by: Alex Shi <alex.shi@linaro.org>
drivers/base/power/opp/core.c