From 82d9921342af4ca7fb898b215d73642694549fd9 Mon Sep 17 00:00:00 2001 From: Artem Shimko Date: Thu, 31 Jul 2025 16:10:02 +0300 Subject: [PATCH v1 2/4] hwmon: scmi: Remove redundant devm_kfree call 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 Signed-off-by: Artem Shimko --- 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); -- 2.43.0