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

Commit e30952e4 authored by Ram Chandrasekar's avatar Ram Chandrasekar
Browse files

drivers: thermal: Avoid race condition in updating the cooling device



Userspace when having a new request for cooling device, will use the
sysfs to vote. Since there can be a simultaneous request coming from
kernel governor, there is a potential race condition in updating the
update pending flag. This could leave a vote be ignored or delayed till
the next update.

Acquire mutex before updating the userspace request and the update
pending flag.

Change-Id: I41c86b92a21c42ecefe1127268958916c3bb5894
Signed-off-by: default avatarRam Chandrasekar <rkumbako@codeaurora.org>
parent d9f72f76
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -1325,9 +1325,11 @@ thermal_cooling_device_cur_state_store(struct device *dev,
	if ((long)state < 0)
		return -EINVAL;

	mutex_lock(&cdev->lock);
	cdev->sysfs_cur_state_req = state;

	cdev->updated = false;
	mutex_unlock(&cdev->lock);
	thermal_cdev_update(cdev);

	return count;
@@ -1349,9 +1351,11 @@ thermal_cooling_device_min_state_store(struct device *dev,
	if ((long)state < 0)
		return -EINVAL;

	mutex_lock(&cdev->lock);
	cdev->sysfs_min_state_req = state;

	cdev->updated = false;
	mutex_unlock(&cdev->lock);
	thermal_cdev_update(cdev);

	return count;