Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b6cc772f authored by Javi Merino's avatar Javi Merino Committed by Zhang Rui
Browse files

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: default avatarJavi Merino <javi.merino@arm.com>
Signed-off-by: default avatarZhang Rui <rui.zhang@intel.com>
parent 84ffe3ec
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -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;
}