diff options
| author | MyungJoo Ham <myungjoo.ham@samsung.com> | 2012-11-21 05:04:51 -0500 |
|---|---|---|
| committer | MyungJoo Ham <myungjoo.ham@samsung.com> | 2012-11-26 05:17:46 -0500 |
| commit | 389baed01edd298c9622c6e28de5e7e250c8767d (patch) | |
| tree | b15058d96fe7c10738f9cc4efa083897add5f7ac /drivers/devfreq | |
| parent | 883d588e556347c4b3221ac492a8acd8a75e730a (diff) | |
PM / devfreq: missing rcu_read_lock() added for find_device_opp()
opp_get_notifier() uses find_device_opp(), which requires to
held rcu_read_lock. In order to keep the notifier-header
valid, we have added rcu_read_lock().
Reported-by: Kees Cook <keescook@chromium.org>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
Diffstat (limited to 'drivers/devfreq')
| -rw-r--r-- | drivers/devfreq/devfreq.c | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c index 45e053e5b139..1a78ad9e1bd0 100644 --- a/drivers/devfreq/devfreq.c +++ b/drivers/devfreq/devfreq.c | |||
| @@ -1023,11 +1023,18 @@ struct opp *devfreq_recommended_opp(struct device *dev, unsigned long *freq, | |||
| 1023 | */ | 1023 | */ |
| 1024 | int devfreq_register_opp_notifier(struct device *dev, struct devfreq *devfreq) | 1024 | int devfreq_register_opp_notifier(struct device *dev, struct devfreq *devfreq) |
| 1025 | { | 1025 | { |
| 1026 | struct srcu_notifier_head *nh = opp_get_notifier(dev); | 1026 | struct srcu_notifier_head *nh; |
| 1027 | int ret = 0; | ||
| 1027 | 1028 | ||
| 1029 | rcu_read_lock(); | ||
| 1030 | nh = opp_get_notifier(dev); | ||
| 1028 | if (IS_ERR(nh)) | 1031 | if (IS_ERR(nh)) |
| 1029 | return PTR_ERR(nh); | 1032 | ret = PTR_ERR(nh); |
| 1030 | return srcu_notifier_chain_register(nh, &devfreq->nb); | 1033 | rcu_read_unlock(); |
| 1034 | if (!ret) | ||
| 1035 | ret = srcu_notifier_chain_register(nh, &devfreq->nb); | ||
| 1036 | |||
| 1037 | return ret; | ||
| 1031 | } | 1038 | } |
| 1032 | 1039 | ||
| 1033 | /** | 1040 | /** |
| @@ -1042,11 +1049,18 @@ int devfreq_register_opp_notifier(struct device *dev, struct devfreq *devfreq) | |||
| 1042 | */ | 1049 | */ |
| 1043 | int devfreq_unregister_opp_notifier(struct device *dev, struct devfreq *devfreq) | 1050 | int devfreq_unregister_opp_notifier(struct device *dev, struct devfreq *devfreq) |
| 1044 | { | 1051 | { |
| 1045 | struct srcu_notifier_head *nh = opp_get_notifier(dev); | 1052 | struct srcu_notifier_head *nh; |
| 1053 | int ret = 0; | ||
| 1046 | 1054 | ||
| 1055 | rcu_read_lock(); | ||
| 1056 | nh = opp_get_notifier(dev); | ||
| 1047 | if (IS_ERR(nh)) | 1057 | if (IS_ERR(nh)) |
| 1048 | return PTR_ERR(nh); | 1058 | ret = PTR_ERR(nh); |
| 1049 | return srcu_notifier_chain_unregister(nh, &devfreq->nb); | 1059 | rcu_read_unlock(); |
| 1060 | if (!ret) | ||
| 1061 | ret = srcu_notifier_chain_unregister(nh, &devfreq->nb); | ||
| 1062 | |||
| 1063 | return ret; | ||
| 1050 | } | 1064 | } |
| 1051 | 1065 | ||
| 1052 | MODULE_AUTHOR("MyungJoo Ham <myungjoo.ham@samsung.com>"); | 1066 | MODULE_AUTHOR("MyungJoo Ham <myungjoo.ham@samsung.com>"); |
