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: d369a5d8fc ("clocksource: convert sysdev_class to a regular subsystem")
Signed-off-by: Yuho Choi <dbgh9129@gmail.com>
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Link: https://patch.msgid.link/20260702215733.84588-1-dbgh9129@gmail.com
This commit is contained in:
Yuho Choi
2026-07-07 23:26:58 +02:00
committed by Thomas Gleixner
parent b4b66151a7
commit 3dee6537e7
+6 -2
View File
@@ -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;
}