mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v1] clocksource: Unregister subsystem on device registration failure
@ 2026-07-02 21:57 Yuho Choi
  2026-07-07 21:32 ` [tip: timers/core] " tip-bot2 for Yuho Choi
  0 siblings, 1 reply; 2+ messages in thread
From: Yuho Choi @ 2026-07-02 21:57 UTC (permalink / raw)
  To: John Stultz, Thomas Gleixner; +Cc: Stephen Boyd, linux-kernel, Yuho Choi

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@gmail.com>
---
 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 e48c4d379a7c..5a786b3c778c 100644
--- a/kernel/time/clocksource.c
+++ b/kernel/time/clocksource.c
@@ -1566,8 +1566,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;
 }
-- 
2.43.0


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

end of thread, other threads:[~2026-07-07 21:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-02 21:57 [PATCH v1] clocksource: Unregister subsystem on device registration failure Yuho Choi
2026-07-07 21:32 ` [tip: timers/core] " tip-bot2 for Yuho Choi

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