From: Dmitry Osipenko Date: Sun, 23 Jun 2019 17:50:53 +0000 (+0300) Subject: opp: Don't use IS_ERR on invalid supplies X-Git-Tag: v5.1.20~95 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=44c92c0c7407b150f50af0c063ddb54c91df3c84;p=thirdparty%2Fkernel%2Fstable.git opp: Don't use IS_ERR on invalid supplies commit 560d1bcad715c215e7ffe5d7cffe045974b623d0 upstream. _set_opp_custom() receives a set of OPP supplies as its arguments and the caller of it passes NULL when the supplies are not valid. But _set_opp_custom(), by mistake, checks for error by performing IS_ERR(old_supply) on it which will always evaluate to false. The problem was spotted during of testing of upcoming update for the NVIDIA Tegra CPUFreq driver. Cc: stable Fixes: 7e535993fa4f ("OPP: Separate out custom OPP handler specific code") Reported-by: Marc Dietrich Signed-off-by: Dmitry Osipenko [ Viresh: Massaged changelog ] Signed-off-by: Viresh Kumar Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 0420f7e8ad5b0..f5d565804e52d 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -631,7 +631,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);