From: Guenter Roeck <linux@roeck-us.net>
To: "a.shimko" <artyom.shimko@gmail.com>, linux-hwmon@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, sudeep.holla@arm.com,
cristian.marussi@arm.com, jdelvare@suse.com,
guenter.roeck@linux.com
Subject: Re: [PATCH 2/3] hwmon: scmi: Remove redundant devm_kfree call
Date: Tue, 5 Aug 2025 06:13:15 -0700 [thread overview]
Message-ID: <af4f80c4-3d31-4e03-8996-2caf2f311b7a@roeck-us.net> (raw)
In-Reply-To: <20250805125003.12573-3-artyom.shimko@gmail.com>
On 8/5/25 05:43, a.shimko wrote:
> From: Artem Shimko <artyom.shimko@gmail.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@gmail.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);
>
next prev parent reply other threads:[~2025-08-05 13:13 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-05 12:43 [PATCH v2 0/3] hwmon: scmi: Driver improvements and fixes a.shimko
2025-08-05 12:43 ` [PATCH 1/3] hwmon: scmi: Add default case with debug output a.shimko
2025-08-05 13:10 ` Guenter Roeck
2025-08-06 15:12 ` kernel test robot
2025-08-05 12:43 ` [PATCH 2/3] hwmon: scmi: Remove redundant devm_kfree call a.shimko
2025-08-05 13:13 ` Guenter Roeck [this message]
2025-08-05 12:43 ` [PATCH 3/3] hwmon: scmi: Enhance error reporting with dev_err_probe a.shimko
2025-08-05 13:20 ` Guenter Roeck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=af4f80c4-3d31-4e03-8996-2caf2f311b7a@roeck-us.net \
--to=linux@roeck-us.net \
--cc=artyom.shimko@gmail.com \
--cc=cristian.marussi@arm.com \
--cc=guenter.roeck@linux.com \
--cc=jdelvare@suse.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sudeep.holla@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®