[PATCH] thermal: intel: int3400: clean up ODVP on probe failures
From: Pengpeng Hou
Date: Mon Jun 15 2026 - 03:04:15 EST
int3400_thermal_probe() calls evaluate_odvp() before several later
fallible setup steps. evaluate_odvp() can allocate ODVP state and create
odvp<N> sysfs files.
If thermal zone registration fails, or if a later sysfs setup step fails
before the notify handler is installed, the current unwind path can free
the private data without removing the ODVP files. The IMOK group failure
path also skips removal of the previously created UUID group.
Make cleanup_odvp() reset its pointers, route the thermal-zone failure
through ODVP cleanup, and make the later sysfs error paths unwind all
previously created sysfs state.
Signed-off-by: Pengpeng Hou <pengpeng@xxxxxxxxxxx>
---
.../intel/int340x_thermal/int3400_thermal.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/drivers/thermal/intel/int340x_thermal/int3400_thermal.c b/drivers/thermal/intel/int340x_thermal/int3400_thermal.c
index d200734625ee..e2278baa328c 100644
--- a/drivers/thermal/intel/int340x_thermal/int3400_thermal.c
+++ b/drivers/thermal/intel/int340x_thermal/int3400_thermal.c
@@ -356,8 +356,10 @@ static void cleanup_odvp(struct int3400_thermal_priv *priv)
kfree(priv->odvp_attrs[i].attr.attr.name);
}
kfree(priv->odvp_attrs);
+ priv->odvp_attrs = NULL;
}
kfree(priv->odvp);
+ priv->odvp = NULL;
priv->odvp_count = 0;
}
@@ -597,7 +599,7 @@ static int int3400_thermal_probe(struct platform_device *pdev)
&int3400_thermal_params);
if (IS_ERR(priv->thermal)) {
result = PTR_ERR(priv->thermal);
- goto free_art_trt;
+ goto free_odvp;
}
priv->rel_misc_dev_res = acpi_thermal_rel_misc_device_add(
@@ -610,13 +612,16 @@ static int int3400_thermal_probe(struct platform_device *pdev)
if (acpi_has_method(priv->adev->handle, "IMOK")) {
result = sysfs_create_group(&pdev->dev.kobj, &imok_attribute_group);
if (result)
- goto free_imok;
+ goto free_uuid;
}
if (!ZERO_OR_NULL_PTR(priv->data_vault)) {
result = device_create_bin_file(&pdev->dev, &bin_attr_data_vault);
- if (result)
+ if (result) {
+ kfree(priv->data_vault);
+ priv->data_vault = NULL;
goto free_uuid;
+ }
}
result = acpi_install_notify_handler(
@@ -639,6 +644,7 @@ static int int3400_thermal_probe(struct platform_device *pdev)
if (!ZERO_OR_NULL_PTR(priv->data_vault)) {
device_remove_bin_file(&pdev->dev, &bin_attr_data_vault);
kfree(priv->data_vault);
+ priv->data_vault = NULL;
}
free_uuid:
sysfs_remove_group(&pdev->dev.kobj, &uuid_attribute_group);
@@ -648,6 +654,8 @@ static int int3400_thermal_probe(struct platform_device *pdev)
if (!priv->rel_misc_dev_res)
acpi_thermal_rel_misc_device_remove(priv->adev->handle);
thermal_zone_device_unregister(priv->thermal);
+free_odvp:
+ cleanup_odvp(priv);
free_art_trt:
kfree(priv->trts);
kfree(priv->arts);
--
2.50.1 (Apple Git-155)