Commit ea37bec5 authored by Guenter Roeck's avatar Guenter Roeck Committed by Rafael J. Wysocki
Browse files

thermal/core: Protect hwmon accesses to thermal operations with thermal zone mutex



In preparation to protecting access to thermal operations against thermal
zone device removal, protect hwmon accesses to thermal zone operations
with the thermal zone mutex. After acquiring the mutex, ensure that the
thermal zone device is registered before proceeding.

Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 1c439dec
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -77,7 +77,15 @@ temp_crit_show(struct device *dev, struct device_attribute *attr, char *buf)
	int temperature;
	int ret;

	mutex_lock(&tz->lock);

	if (device_is_registered(&tz->device))
		ret = tz->ops->get_crit_temp(tz, &temperature);
	else
		ret = -ENODEV;

	mutex_unlock(&tz->lock);

	if (ret)
		return ret;