diff mbox series

[4.4.y-cip,17/23] PM / OPP: Fix NULL pointer dereference crash when disabling OPPs

Message ID 20200708154554.26450-18-wens@csie.org (mailing list archive)
State Changes Requested
Headers show
Series PM / OPP v2 & cpufreq backports part 2 | expand

Commit Message

Chen-Yu Tsai July 8, 2020, 3:45 p.m. UTC
From: Jon Hunter <jonathanh@nvidia.com>

commit 78ecc56247f0ec2bc0cf6f2f2af69e98d99767bc upstream.

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>
Signed-off-by: Chen-Yu Tsai (Moxa) <wens@csie.org>
---
 drivers/base/power/opp/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Pavel Machek July 14, 2020, 5:37 p.m. UTC | #1
Hi!

On Wed 2020-07-08 23:45:48, Chen-Yu Tsai (Moxa) wrote:
> From: Jon Hunter <jonathanh@nvidia.com>
> 
> commit 78ecc56247f0ec2bc0cf6f2f2af69e98d99767bc upstream.
> 
> 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

So this one should be close to the patch it fixes, or maybe squashed
together.

Best regards,
								Pavel

> diff --git a/drivers/base/power/opp/core.c b/drivers/base/power/opp/core.c
> index 91b4cc261d84a..067379f931662 100644
> --- a/drivers/base/power/opp/core.c
> +++ b/drivers/base/power/opp/core.c
> @@ -975,7 +975,7 @@ static bool _opp_supported_by_regulators(struct dev_pm_opp *opp,
>  {
>  	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,
>  					    opp->u_volt_max)) {
>  		pr_warn("%s: OPP minuV: %lu maxuV: %lu, not supported by regulator\n",
diff mbox series

Patch

diff --git a/drivers/base/power/opp/core.c b/drivers/base/power/opp/core.c
index 91b4cc261d84a..067379f931662 100644
--- a/drivers/base/power/opp/core.c
+++ b/drivers/base/power/opp/core.c
@@ -975,7 +975,7 @@  static bool _opp_supported_by_regulators(struct dev_pm_opp *opp,
 {
 	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,
 					    opp->u_volt_max)) {
 		pr_warn("%s: OPP minuV: %lu maxuV: %lu, not supported by regulator\n",