]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
opp: Don't use IS_ERR on invalid supplies
authorDmitry Osipenko <digetx@gmail.com>
Sun, 23 Jun 2019 17:50:53 +0000 (20:50 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 26 Jul 2019 07:10:54 +0000 (09:10 +0200)
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 <stable@vger.kernel.org>
Fixes: 7e535993fa4f ("OPP: Separate out custom OPP handler specific code")
Reported-by: Marc Dietrich <marvin24@gmx.de>
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
[ Viresh: Massaged changelog ]
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/opp/core.c

index 3a9789388bfb947980c35f540c3cf86d51ec4b83..6b2f7cadec3c5e08902f68060186e7deb70198a9 100644 (file)
@@ -682,7 +682,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);