diff options
author | Javi Merino <javi.merino@arm.com> | 2014-11-25 16:00:33 +0000 |
---|---|---|
committer | Kevin Hilman <khilman@linaro.org> | 2015-06-05 15:42:06 -0700 |
commit | 2565094fbf51d60bf7cc78f0c6960d27799e7c35 (patch) | |
tree | c9d0653fbc0265158a3f04e65281448c10bf1c78 | |
parent | 604b9b1606390d99782790e3a4133d7f52bd6231 (diff) |
thermal: lock the thermal zone when switching governors
Currently, userspace can request a governor change while the governor
itself is running. Grab the thermal zone lock when changing the
governor to prevent this race.
Signed-off-by: Javi Merino <javi.merino@arm.com>
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
(cherry picked from commit b6cc772f64ac7d1917770406844b73a94ca5ef06)
Signed-off-by: Kevin Hilman <khilman@linaro.org>
-rw-r--r-- | drivers/thermal/thermal_core.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 5aa57736fa9e..7b723c7c4cae 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -757,6 +757,7 @@ policy_store(struct device *dev, struct device_attribute *attr, snprintf(name, sizeof(name), "%s", buf); mutex_lock(&thermal_governor_lock); + mutex_lock(&tz->lock); gov = __find_governor(strim(name)); if (!gov) @@ -766,6 +767,7 @@ policy_store(struct device *dev, struct device_attribute *attr, ret = count; exit: + mutex_unlock(&tz->lock); mutex_unlock(&thermal_governor_lock); return ret; } |