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] [thread-next>] [day] [month] [year] [list]
Message-ID: <af4f80c4-3d31-4e03-8996-2caf2f311b7a@roeck-us.net>
Date: Tue, 5 Aug 2025 06:13:15 -0700
From: Guenter Roeck <linux@...ck-us.net>
To: "a.shimko" <artyom.shimko@...il.com>, linux-hwmon@...r.kernel.org
Cc: linux-kernel@...r.kernel.org, sudeep.holla@....com,
 cristian.marussi@....com, jdelvare@...e.com, guenter.roeck@...ux.com
Subject: Re: [PATCH 2/3] hwmon: scmi: Remove redundant devm_kfree call

On 8/5/25 05:43, a.shimko wrote:
> From: Artem Shimko <artyom.shimko@...il.com>
> 
> Fix potential resource management issue by:
> - Removing unnecessary devm_kfree() call in error path
> - Relying on devres automatic cleanup
> - Preserving all error handling logic
> 
> Rationale:
> - Memory was allocated with devm_kzalloc()
> - devm_ thermal registration manages its own resources
> - Double-free could occur during probe failure

The reason for calling devm_kfree() is to avoid holding the memory
unnecessarily until the driver deregisters. There is no double free since
the code calls devm_kfree(), not kfree().

The reasoning is wrong, and the patch does not add value.

Guenter

> 
> Signed-off-by: Artem Shimko <artyom.shimko@...il.com>
> ---
>   drivers/hwmon/scmi-hwmon.c | 2 --
>   1 file changed, 2 deletions(-)
> 
> diff --git a/drivers/hwmon/scmi-hwmon.c b/drivers/hwmon/scmi-hwmon.c
> index a3b5b5c0ec25..d03174922e65 100644
> --- a/drivers/hwmon/scmi-hwmon.c
> +++ b/drivers/hwmon/scmi-hwmon.c
> @@ -211,8 +211,6 @@ static int scmi_thermal_sensor_register(struct device *dev,
>   	tzd = devm_thermal_of_zone_register(dev, th_sensor->info->id, th_sensor,
>   					    &scmi_hwmon_thermal_ops);
>   	if (IS_ERR(tzd)) {
> -		devm_kfree(dev, th_sensor);
> -
>   		if (PTR_ERR(tzd) != -ENODEV)
>   			return PTR_ERR(tzd);
>   


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ