Linux ACPI
 help / color / mirror / Atom feed
* [PATCH v1] ACPI: sysfs: Fix hotplug kobject cleanup on failure
@ 2026-07-02 23:25 Yuho Choi
  0 siblings, 0 replies; only message in thread
From: Yuho Choi @ 2026-07-02 23:25 UTC (permalink / raw)
  To: Rafael J. Wysocki, Len Brown
  Cc: Toshi Kani, linux-acpi, linux-kernel, Yuho Choi

acpi_sysfs_init() creates the ACPI hotplug kobject and the force_remove
sysfs file before creating the pm_profile file. If force_remove creation
fails, the hotplug kobject is left behind. If pm_profile creation fails,
both force_remove and the hotplug kobject are left behind.

Add the missing unwind paths so the partial hotplug sysfs state is
removed before returning an error.

Fixes: 683058e315f0 ("ACPI / hotplug: Use device offline/online for graceful hot-removal")
Signed-off-by: Yuho Choi <dbgh9129@gmail.com>
---
 drivers/acpi/sysfs.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
index 908cc5c7e643..0b642ba1a526 100644
--- a/drivers/acpi/sysfs.c
+++ b/drivers/acpi/sysfs.c
@@ -1037,8 +1037,18 @@ int __init acpi_sysfs_init(void)
 
 	result = sysfs_create_file(hotplug_kobj, &force_remove_attr.attr);
 	if (result)
-		return result;
+		goto err_hotplug;
 
 	result = sysfs_create_file(acpi_kobj, &pm_profile_attr.attr);
+	if (result)
+		goto err_force_remove;
+
+	return 0;
+
+err_force_remove:
+	sysfs_remove_file(hotplug_kobj, &force_remove_attr.attr);
+err_hotplug:
+	kobject_put(hotplug_kobj);
+	hotplug_kobj = NULL;
 	return result;
 }
-- 
2.43.0


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-07-02 23:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-02 23:25 [PATCH v1] ACPI: sysfs: Fix hotplug kobject cleanup on failure Yuho Choi

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