diff options
| author | Yuho Choi <dbgh9129@gmail.com> | 2026-07-02 17:57:33 -0400 |
|---|---|---|
| committer | Thomas Gleixner <tglx@kernel.org> | 2026-07-07 23:26:58 +0200 |
| commit | 3dee6537e728bd8137fda6eaf859f26e685943f7 (patch) | |
| tree | 7a547c56aae190f2d1c7c7c80d31a581ee1775e9 /kernel/time | |
| parent | b4b66151a71445f3a71574136ddc82968c7b175e (diff) | |
| download | linux-next-3dee6537e728bd8137fda6eaf859f26e685943f7.tar.gz linux-next-3dee6537e728bd8137fda6eaf859f26e685943f7.zip | |
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@gmail.com>
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Link: https://patch.msgid.link/20260702215733.84588-1-dbgh9129@gmail.com
Diffstat (limited to 'kernel/time')
| -rw-r--r-- | kernel/time/clocksource.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c index 78c91b0037f7..f1253f5795c6 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; } |
