[tip: timers/core] clocksource: Unregister subsystem on device registration failure
From: tip-bot2 for Yuho Choi
Date: Tue Jul 07 2026 - 17:34:21 EST
The following commit has been merged into the timers/core branch of tip:
Commit-ID: 3dee6537e728bd8137fda6eaf859f26e685943f7
Gitweb: https://git.kernel.org/tip/3dee6537e728bd8137fda6eaf859f26e685943f7
Author: Yuho Choi <dbgh9129@xxxxxxxxx>
AuthorDate: Thu, 02 Jul 2026 17:57:33 -04:00
Committer: Thomas Gleixner <tglx@xxxxxxxxxx>
CommitterDate: Tue, 07 Jul 2026 23:26:58 +02:00
clocksource: Unregister subsystem on device registration failure
init_clocksource_sysfs() registers the clocksource subsystem before
registering the clocksource device. If device_register() fails, the
function returns the error while leaving the subsystem registered.
Unregister the clocksource subsystem on that failure path so the
successful subsystem registration is unwound before returning.
Fixes: d369a5d8fc70 ("clocksource: convert sysdev_class to a regular subsystem")
Signed-off-by: Yuho Choi <dbgh9129@xxxxxxxxx>
Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxx>
Link: https://patch.msgid.link/20260702215733.84588-1-dbgh9129@xxxxxxxxx
---
kernel/time/clocksource.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c
index 78c91b0..f1253f5 100644
--- a/kernel/time/clocksource.c
+++ b/kernel/time/clocksource.c
@@ -1565,8 +1565,12 @@ static int __init init_clocksource_sysfs(void)
{
int error = subsys_system_register(&clocksource_subsys, NULL);
- if (!error)
- error = device_register(&device_clocksource);
+ if (error)
+ return error;
+
+ error = device_register(&device_clocksource);
+ if (error)
+ bus_unregister(&clocksource_subsys);
return error;
}