PM / devfreq: stopping the governor before device_unregister()
authorVincent Donnefort <vincent.donnefort@arm.com>
Mon, 3 Sep 2018 00:02:07 +0000 (09:02 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 24 Nov 2019 07:19:36 +0000 (08:19 +0100)
commitf6ec4fccbf9ac23feea3ae85470d9083c5a04663
treee82623768b4504a913fb3e29e1e818448b0ad83b
parentfc491a1e77be398b53a264c6d9956c83fcabc46e
PM / devfreq: stopping the governor before device_unregister()

[ Upstream commit 2f061fd0c2d852e32e03a903fccd810663c5c31e ]

device_release() is freeing the resources before calling the device
specific release callback which is, in the case of devfreq, stopping
the governor.

It is a problem as some governors are using the device resources. e.g.
simpleondemand which is using the devfreq deferrable monitoring work. If it
is not stopped before the resources are freed, it might lead to a use after
free.

Signed-off-by: Vincent Donnefort <vincent.donnefort@arm.com>
Reviewed-by: John Einar Reitan <john.reitan@arm.com>
[cw00.choi: Fix merge conflict]
Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/devfreq/devfreq.c