Linux Power Management development
 help / color / mirror / Atom feed
* [PATCH] thermal: intel: int3400: clean up ODVP on probe failures
@ 2026-06-15  7:03 Pengpeng Hou
  2026-06-15 12:25 ` kernel test robot
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Pengpeng Hou @ 2026-06-15  7:03 UTC (permalink / raw)
  To: Rafael J. Wysocki, Daniel Lezcano, Zhang Rui, Lukasz Luba,
	Srinivas Pandruvada, Kaushlendra Kumar, Kees Cook, Miquel Raynal,
	Christophe JAILLET, linux-pm, linux-kernel
  Cc: pengpeng

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@iscas.ac.cn>
---
 .../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)


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-06-15 15:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-15  7:03 [PATCH] thermal: intel: int3400: clean up ODVP on probe failures Pengpeng Hou
2026-06-15 12:25 ` kernel test robot
2026-06-15 14:13 ` kernel test robot
2026-06-15 14:24 ` kernel test robot
2026-06-15 15:47 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox