lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <ae5f1ab3-cd0e-4831-9a11-30dc75f16da0@roeck-us.net>
Date: Fri, 30 Jan 2026 07:44:24 -0800
From: Guenter Roeck <linux@...ck-us.net>
To: linux-hwmon@...r.kernel.org
Cc: linux-doc@...r.kernel.org, linux-kernel@...r.kernel.org,
 Jaroslav Pulchart <jaroslav.pulchart@...ddata.com>,
 "Rafael J . Wysocki" <rafael@...nel.org>, lihuisong <lihuisong@...wei.com>
Subject: Re: [PATCH RFT 3/5] hwmon: Add support for updating thermal zones

On 1/23/26 10:22, Guenter Roeck wrote:
> Implement support for updating thermal zones. This is necessary
> to be able to handle updates to sysfs attribute visibility.
> 
> Signed-off-by: Guenter Roeck <linux@...ck-us.net>

This patch is both racy because it doesn't protect the list of thermal
zones, and it leaks tzdata until the device is removed. SO it will need
(much) more work.

Guenter

> ---
>   drivers/hwmon/hwmon.c | 34 +++++++++++++++++++++++++++-------
>   1 file changed, 27 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c
> index 1f35285ca7a0..cb89218a0b6a 100644
> --- a/drivers/hwmon/hwmon.c
> +++ b/drivers/hwmon/hwmon.c
> @@ -276,7 +276,7 @@ static struct hwmon_thermal_data *hwmon_thermal_find_tz(struct device *dev, int
>   	return NULL;
>   }
>   
> -static int hwmon_thermal_register_sensors(struct device *dev)
> +static int hwmon_thermal_handle_sensors(struct device *dev, bool update)
>   {
>   	struct hwmon_device *hwdev = to_hwmon_device(dev);
>   	const struct hwmon_chip_info *chip = hwdev->chip;
> @@ -294,22 +294,42 @@ static int hwmon_thermal_register_sensors(struct device *dev)
>   			continue;
>   
>   		for (j = 0; info[i]->config[j]; j++) {
> +			umode_t mode;
>   			int err;
>   
> -			if (!(info[i]->config[j] & HWMON_T_INPUT) ||
> -			    !hwmon_is_visible(chip->ops, drvdata, hwmon_temp,
> -					      hwmon_temp_input, j))
> +			if (!(info[i]->config[j] & HWMON_T_INPUT))
>   				continue;
> +			mode = hwmon_is_visible(chip->ops, drvdata, hwmon_temp,
> +						hwmon_temp_input, j);
> +			if (!mode) {
> +				struct hwmon_thermal_data *tzdata;
>   
> -			err = hwmon_thermal_add_sensor(dev, j);
> -			if (err)
> -				return err;
> +				if (!update)
> +					continue;
> +				tzdata = hwmon_thermal_find_tz(dev, j);
> +				if (tzdata) {
> +					devm_thermal_of_zone_unregister(dev, tzdata->tzd);
> +					devm_release_action(dev, hwmon_thermal_remove_sensor,
> +							    &tzdata->node);
> +				}
> +			} else {
> +				if (!update || !hwmon_thermal_find_tz(dev, j)) {
> +					err = hwmon_thermal_add_sensor(dev, j);
> +					if (err)
> +						return err;
> +				}
> +			}
>   		}
>   	}
>   
>   	return 0;
>   }
>   
> +static int hwmon_thermal_register_sensors(struct device *dev)
> +{
> +	return hwmon_thermal_handle_sensors(dev, false);
> +}
> +
>   static void hwmon_thermal_notify(struct device *dev, int index)
>   {
>   	struct hwmon_thermal_data *tzdata = hwmon_thermal_find_tz(dev, index);


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ