* RE: [PATCH] PM / devfreq: Add proper locking around list_del()
[not found] <CGME20160928091837epcas1p2e3a1fbf609e57b789c503ce4c1799dd1@epcas1p2.samsung.com>
@ 2016-09-29 2:02 ` MyungJoo Ham
0 siblings, 0 replies; 2+ messages in thread
From: MyungJoo Ham @ 2016-09-29 2:02 UTC (permalink / raw)
To: Axel Lin, Rafael J . Wysocki
Cc: Chanwoo Choi, Kyungmin Park, linux-pm, linux-samsung-soc
[-- Attachment #1: Type: text/plain, Size: 1199 bytes --]
> Use devfreq_list_lock around list_del() to prevent list corruption.
>
> Signed-off-by: Axel Lin <axel.lin@ingics.com>
> ---
> drivers/devfreq/devfreq.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
> index 478006b..70369b0 100644
> --- a/drivers/devfreq/devfreq.c
> +++ b/drivers/devfreq/devfreq.c
> @@ -604,7 +604,10 @@ struct devfreq *devfreq_add_device(struct device *dev,
> return devfreq;
>
> err_init:
> + mutex_lock(&devfreq_list_lock);
> list_del(&devfreq->node);
> + mutex_unlock(&devfreq_list_lock);
> +
> device_unregister(&devfreq->dev);
> err_out:
> return ERR_PTR(err);
I'd rather modify:
- mutex_unlock(&devfreq_list_lock);
if (err) {
dev_err(dev, "%s: Unable to start governor for the device\n",
__func__);
goto err_init;
}
+ mutex_unlock(&devfreq_list_lock);
return devfreq;
err_init:
list_del(&devfreq->node);
device_unregister(&devfreq->dev);
+ mutex_unlock(&devfreq_list_lock);
How do you think?
Cheers,
MyungJoo
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH] PM / devfreq: Add proper locking around list_del()
@ 2016-09-28 9:17 Axel Lin
0 siblings, 0 replies; 2+ messages in thread
From: Axel Lin @ 2016-09-28 9:17 UTC (permalink / raw)
To: Rafael J . Wysocki
Cc: Chanwoo Choi, MyungJoo Ham, Kyungmin Park, linux-pm,
linux-samsung-soc, Axel Lin
Use devfreq_list_lock around list_del() to prevent list corruption.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
drivers/devfreq/devfreq.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
index 478006b..70369b0 100644
--- a/drivers/devfreq/devfreq.c
+++ b/drivers/devfreq/devfreq.c
@@ -604,7 +604,10 @@ struct devfreq *devfreq_add_device(struct device *dev,
return devfreq;
err_init:
+ mutex_lock(&devfreq_list_lock);
list_del(&devfreq->node);
+ mutex_unlock(&devfreq_list_lock);
+
device_unregister(&devfreq->dev);
err_out:
return ERR_PTR(err);
--
2.7.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-09-29 2:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <CGME20160928091837epcas1p2e3a1fbf609e57b789c503ce4c1799dd1@epcas1p2.samsung.com>
2016-09-29 2:02 ` [PATCH] PM / devfreq: Add proper locking around list_del() MyungJoo Ham
2016-09-28 9:17 Axel Lin
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.