opp: Don't drop reference for an OPP table that was never parsed
authorViresh Kumar <viresh.kumar@linaro.org>
Mon, 31 Aug 2020 07:33:06 +0000 (13:03 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 9 Sep 2020 17:14:19 +0000 (19:14 +0200)
commite5d5c3b4e4a27ba8b36401d019c37c61e4e45a8c
treee6529016b07ce436fce3463144b812e84e3dd0c1
parent3484b664521d5060a911b333d10059af578edde2
opp: Don't drop reference for an OPP table that was never parsed

[ Upstream commit 922ff0759a16299e24cacfc981ac07914d8f1826 ]

dev_pm_opp_remove_table() should drop a reference to the OPP table only
if the DT OPP table was parsed earlier with a call to
dev_pm_opp_of_add_table() earlier. Else it may end up dropping the
reference to the OPP table, which was added as a result of other calls
like dev_pm_opp_set_clkname(). And would hence result in undesirable
behavior later on when caller would try to free the resource again.

Fixes: 03758d60265c ("opp: Replace list_kref with a local counter")
Reported-by: Naresh Kamboju <naresh.kamboju@linaro.org>
Reported-by: Anders Roxell <anders.roxell@linaro.org>
Tested-by: Naresh Kamboju <naresh.kamboju@linaro.org>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/opp/core.c
drivers/opp/opp.h