Fix NULL dereference caused by a typo in the code. In particular it happens when CPU is running on a frequency which has unsupportable voltage (by regulator) defined in the OPP table and a custom set_opp() callback is being used. The problem was spotted during of testing of upcoming update for the NVIDIA Tegra CPUFreq driver. Cc: stable <stable@xxxxxxxxxxxxxxx> Fixes: 7e535993fa4f ("OPP: Separate out custom OPP handler specific code") Reported-by: Marc Dietrich <marvin24@xxxxxx> Signed-off-by: Dmitry Osipenko <digetx@xxxxxxxxx> --- drivers/opp/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 9fda9a0ec016..89ec6aa220cf 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -685,7 +685,7 @@ static int _set_opp_custom(const struct opp_table *opp_table, data->old_opp.rate = old_freq; size = sizeof(*old_supply) * opp_table->regulator_count; - if (IS_ERR(old_supply)) + if (!old_supply) memset(data->old_opp.supplies, 0, size); else memcpy(data->old_opp.supplies, old_supply, size); -- 2.22.0