mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-06 01:49:46 +00:00
thermal_hwmon: Sanitize thermal_zone type
[ Upstream commit8c7aa18428] When calling thermal_add_hwmon_sysfs(), the device type is sanitized by replacing '-' with '_'. However tz->type remains unsanitized. Thus calling thermal_hwmon_lookup_by_type() returns no device. And if there is no device, thermal_remove_hwmon_sysfs() fails with "hwmon device lookup failed!". The result is unregisted hwmon devices in the sysfs. Fixes:409ef0baca("thermal_hwmon: Sanitize attribute name passed to hwmon") Signed-off-by: Stefan Mavrodiev <stefan@olimex.com> Signed-off-by: Zhang Rui <rui.zhang@intel.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
427cc63503
commit
4baa940f14
@@ -87,13 +87,17 @@ static struct thermal_hwmon_device *
|
||||
thermal_hwmon_lookup_by_type(const struct thermal_zone_device *tz)
|
||||
{
|
||||
struct thermal_hwmon_device *hwmon;
|
||||
char type[THERMAL_NAME_LENGTH];
|
||||
|
||||
mutex_lock(&thermal_hwmon_list_lock);
|
||||
list_for_each_entry(hwmon, &thermal_hwmon_list, node)
|
||||
if (!strcmp(hwmon->type, tz->type)) {
|
||||
list_for_each_entry(hwmon, &thermal_hwmon_list, node) {
|
||||
strcpy(type, tz->type);
|
||||
strreplace(type, '-', '_');
|
||||
if (!strcmp(hwmon->type, type)) {
|
||||
mutex_unlock(&thermal_hwmon_list_lock);
|
||||
return hwmon;
|
||||
}
|
||||
}
|
||||
mutex_unlock(&thermal_hwmon_list_lock);
|
||||
|
||||
return NULL;
|
||||
|
||||
Reference in New Issue
Block a user