From: Yuho Choi <dbgh9129@gmail.com>
To: mcgrof@kernel.org, russ.weight@linux.dev, dakr@kernel.org,
gregkh@linuxfoundation.org, rafael@kernel.org,
nixiaoming@huawei.com
Cc: driver-core@lists.linux.dev, linux-kernel@vger.kernel.org,
Yuho Choi <dbgh9129@gmail.com>
Subject: [PATCH v1] firmware_loader: Unwind initialization on sysfs failure
Date: Sun, 2 Aug 2026 21:29:41 -0400 [thread overview]
Message-ID: <20260803012941.610268-1-dbgh9129@gmail.com> (raw)
firmware_class_init() leaves the firmware PM operations and reboot
notifier registered when register_sysfs_loader() fails. In addition, the
sysfs loader can leave the firmware class registered if its sysctl setup
fails.
Unwind the reboot notifier and firmware PM operations when sysfs loader
registration fails. Make register_sysfs_loader() transactional by
unregistering the firmware class if its sysctl registration fails.
Fixes: 6bb9cf3aa3ed ("firmware: provide helpers for registering the syfs loader")
Fixes: 6aad36d421d8 ("firmware_loader: move firmware sysctl to its own files")
Signed-off-by: Yuho Choi <dbgh9129@gmail.com>
---
drivers/base/firmware_loader/main.c | 8 +++++++-
drivers/base/firmware_loader/sysfs.c | 7 ++++++-
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/drivers/base/firmware_loader/main.c b/drivers/base/firmware_loader/main.c
index 24213a0ea831..c2f7825dfc4a 100644
--- a/drivers/base/firmware_loader/main.c
+++ b/drivers/base/firmware_loader/main.c
@@ -1727,8 +1727,14 @@ static int __init firmware_class_init(void)
if (ret)
goto out;
- return register_sysfs_loader();
+ ret = register_sysfs_loader();
+ if (ret)
+ goto out_reboot;
+
+ return 0;
+out_reboot:
+ unregister_reboot_notifier(&fw_shutdown_nb);
out:
unregister_fw_pm_ops();
return ret;
diff --git a/drivers/base/firmware_loader/sysfs.c b/drivers/base/firmware_loader/sysfs.c
index 29a10d2ad537..d9deb0804f55 100644
--- a/drivers/base/firmware_loader/sysfs.c
+++ b/drivers/base/firmware_loader/sysfs.c
@@ -117,7 +117,12 @@ int register_sysfs_loader(void)
if (ret != 0)
return ret;
- return register_firmware_config_sysctl();
+
+ ret = register_firmware_config_sysctl();
+ if (ret)
+ class_unregister(&firmware_class);
+
+ return ret;
}
void unregister_sysfs_loader(void)
--
2.43.0
next reply other threads:[~2026-08-03 1:29 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-03 1:29 Yuho Choi [this message]
2026-08-06 21:46 ` [PATCH v1] firmware_loader: Unwind initialization on sysfs failure Danilo Krummrich
2026-08-06 23:51 ` 최유호
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=20260803012941.610268-1-dbgh9129@gmail.com \
--to=dbgh9129@gmail.com \
--cc=dakr@kernel.org \
--cc=driver-core@lists.linux.dev \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mcgrof@kernel.org \
--cc=nixiaoming@huawei.com \
--cc=rafael@kernel.org \
--cc=russ.weight@linux.dev \
/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