From: Yuho Choi <dbgh9129@gmail.com>
To: "Rafael J. Wysocki" <rafael@kernel.org>, Len Brown <lenb@kernel.org>
Cc: Toshi Kani <toshi.kani@hp.com>,
linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org,
Yuho Choi <dbgh9129@gmail.com>
Subject: [PATCH v1] ACPI: sysfs: Fix hotplug kobject cleanup on failure
Date: Thu, 2 Jul 2026 19:25:55 -0400 [thread overview]
Message-ID: <20260702232555.96539-1-dbgh9129@gmail.com> (raw)
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
reply other threads:[~2026-07-02 23:26 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260702232555.96539-1-dbgh9129@gmail.com \
--to=dbgh9129@gmail.com \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=toshi.kani@hp.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