提交 f6ec4fcc 编写于 作者: V Vincent Donnefort 提交者: Greg Kroah-Hartman

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: NVincent Donnefort <vincent.donnefort@arm.com>
Reviewed-by: NJohn Einar Reitan <john.reitan@arm.com>
[cw00.choi: Fix merge conflict]
Reviewed-by: NChanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: NMyungJoo Ham <myungjoo.ham@samsung.com>
Signed-off-by: NSasha Levin <sashal@kernel.org>
上级 fc491a1e
...@@ -578,10 +578,6 @@ static void devfreq_dev_release(struct device *dev) ...@@ -578,10 +578,6 @@ static void devfreq_dev_release(struct device *dev)
list_del(&devfreq->node); list_del(&devfreq->node);
mutex_unlock(&devfreq_list_lock); mutex_unlock(&devfreq_list_lock);
if (devfreq->governor)
devfreq->governor->event_handler(devfreq,
DEVFREQ_GOV_STOP, NULL);
if (devfreq->profile->exit) if (devfreq->profile->exit)
devfreq->profile->exit(devfreq->dev.parent); devfreq->profile->exit(devfreq->dev.parent);
...@@ -717,7 +713,7 @@ struct devfreq *devfreq_add_device(struct device *dev, ...@@ -717,7 +713,7 @@ struct devfreq *devfreq_add_device(struct device *dev,
err_init: err_init:
mutex_unlock(&devfreq_list_lock); mutex_unlock(&devfreq_list_lock);
device_unregister(&devfreq->dev); devfreq_remove_device(devfreq);
devfreq = NULL; devfreq = NULL;
err_dev: err_dev:
if (devfreq) if (devfreq)
...@@ -738,6 +734,9 @@ int devfreq_remove_device(struct devfreq *devfreq) ...@@ -738,6 +734,9 @@ int devfreq_remove_device(struct devfreq *devfreq)
if (!devfreq) if (!devfreq)
return -EINVAL; return -EINVAL;
if (devfreq->governor)
devfreq->governor->event_handler(devfreq,
DEVFREQ_GOV_STOP, NULL);
device_unregister(&devfreq->dev); device_unregister(&devfreq->dev);
return 0; return 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册