@@ -682,8 +682,13 @@ thermal_cooling_device_type_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct thermal_cooling_device *cdev = to_cooling_device(dev);
+ char *type;
+
+ mutex_lock(&cdev->lock);
+ type = cdev->type;
+ mutex_unlock(&cdev->lock);
- return sprintf(buf, "%s\n", cdev->type);
+ return sprintf(buf, "%s\n", type);
}
static ssize_t
@@ -137,7 +137,7 @@ struct thermal_cooling_device {
void *devdata;
const struct thermal_cooling_device_ops *ops;
bool updated; /* true if the cooling device does not need update */
- struct mutex lock; /* protect thermal_instances list */
+ struct mutex lock; /* protect thermal_cooling_device */
struct list_head thermal_instances;
struct list_head node;
};
Serialized data access to cdev->type in user facing sysfs handler thermal_cooling_device_type_show(). The existing cdev lock is used. Updating comment on the lock definition. Cc: Zhang Rui <rui.zhang@intel.com> Cc: linux-pm@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Eduardo Valentin <edubezval@gmail.com> --- drivers/thermal/thermal_sysfs.c | 7 ++++++- include/linux/thermal.h | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-)