mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2026-09-22 09:34:56 +02:00
thermal: hwmon: Fix critical temperature attribute removal
[ Upstream commitc2114dbda0] Since the return value of thermal_zone_crit_temp_valid() depends on the behavior of the thermal zone .get_crit_temp() callback which may change over time in theory, thermal_remove_hwmon_sysfs() may attempt to remove a critical temperature attribute that has not been created, passing a pointer to an uninitialized attribute structure to device_remove_file(). To avoid that, set a flag in struct thermal_hwmon_temp after creating a critical temperature attribute and use the value of that flag to decide whether or not the attribute needs to be removed. Fixes:e8db5d6736("thermal: hwmon: Make the check for critical temp valid consistent") Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Link: https://patch.msgid.link/2437056.ElGaqSPkdT@rafael.j.wysocki Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
a36cbfb85f
commit
345675e960
@@ -40,6 +40,7 @@ struct thermal_hwmon_temp {
|
||||
struct thermal_zone_device *tz;
|
||||
struct thermal_hwmon_attr temp_input; /* hwmon sys attr */
|
||||
struct thermal_hwmon_attr temp_crit; /* hwmon sys attr */
|
||||
bool temp_crit_present;
|
||||
};
|
||||
|
||||
static LIST_HEAD(thermal_hwmon_list);
|
||||
@@ -197,6 +198,8 @@ int thermal_add_hwmon_sysfs(struct thermal_zone_device *tz)
|
||||
&temp->temp_crit.attr);
|
||||
if (result)
|
||||
goto unregister_input;
|
||||
|
||||
temp->temp_crit_present = true;
|
||||
}
|
||||
|
||||
mutex_lock(&thermal_hwmon_list_lock);
|
||||
@@ -241,7 +244,7 @@ void thermal_remove_hwmon_sysfs(struct thermal_zone_device *tz)
|
||||
}
|
||||
|
||||
device_remove_file(hwmon->device, &temp->temp_input.attr);
|
||||
if (thermal_zone_crit_temp_valid(tz))
|
||||
if (temp->temp_crit_present)
|
||||
device_remove_file(hwmon->device, &temp->temp_crit.attr);
|
||||
|
||||
mutex_lock(&thermal_hwmon_list_lock);
|
||||
|
||||
Reference in New Issue
Block a user