* [PATCH] clockevents: Add error handling and rollback in tick_init_sysfs()
@ 2026-02-10 7:27 Zhan Xusheng
2026-02-11 12:58 ` Thomas Gleixner
0 siblings, 1 reply; 2+ messages in thread
From: Zhan Xusheng @ 2026-02-10 7:27 UTC (permalink / raw)
To: Frederic Weisbecker; +Cc: linux-kernel, Zhan Xusheng
Ensure proper error handling and logging when creating device files for
each CPU. If device creation or file creation fails, the function now
properly unregisters the device and removes any previously created files
to maintain system consistency.
Signed-off-by: Zhan Xusheng <zhanxusheng@xiaomi.com>
---
kernel/time/clockevents.c | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/kernel/time/clockevents.c b/kernel/time/clockevents.c
index eaae1ce9f060..daa875f1d37c 100644
--- a/kernel/time/clockevents.c
+++ b/kernel/time/clockevents.c
@@ -756,12 +756,24 @@ static int __init tick_init_sysfs(void)
dev->id = cpu;
dev->bus = &clockevents_subsys;
err = device_register(dev);
- if (!err)
- err = device_create_file(dev, &dev_attr_current_device);
- if (!err)
- err = device_create_file(dev, &dev_attr_unbind_device);
if (err)
return err;
+
+ err = device_create_file(dev, &dev_attr_current_device);
+ if (err)
+ goto err_unregister;
+
+ err = device_create_file(dev, &dev_attr_unbind_device);
+ if (err)
+ goto err_remove_file;
+
+ continue;
+
+err_remove_file:
+ device_remove_file(dev, &dev_attr_current_device);
+err_unregister:
+ device_unregister(dev);
+ return err;
}
return tick_broadcast_init_sysfs();
}
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] clockevents: Add error handling and rollback in tick_init_sysfs()
2026-02-10 7:27 [PATCH] clockevents: Add error handling and rollback in tick_init_sysfs() Zhan Xusheng
@ 2026-02-11 12:58 ` Thomas Gleixner
0 siblings, 0 replies; 2+ messages in thread
From: Thomas Gleixner @ 2026-02-11 12:58 UTC (permalink / raw)
To: Zhan Xusheng, Frederic Weisbecker; +Cc: linux-kernel, Zhan Xusheng
On Tue, Feb 10 2026 at 15:27, Zhan Xusheng wrote:
> @@ -756,12 +756,24 @@ static int __init tick_init_sysfs(void)
> dev->id = cpu;
> dev->bus = &clockevents_subsys;
> err = device_register(dev);
> - if (!err)
> - err = device_create_file(dev, &dev_attr_current_device);
> - if (!err)
> - err = device_create_file(dev, &dev_attr_unbind_device);
> if (err)
> return err;
> +
> + err = device_create_file(dev, &dev_attr_current_device);
> + if (err)
> + goto err_unregister;
> +
> + err = device_create_file(dev, &dev_attr_unbind_device);
> + if (err)
> + goto err_remove_file;
> +
> + continue;
> +
> +err_remove_file:
> + device_remove_file(dev, &dev_attr_current_device);
> +err_unregister:
> + device_unregister(dev);
> + return err;
So this leaves already created per CPU files and devices around which is
inconsistent as well.
So what's the point of this half baked cleanup?
If this fails and it only can fail because of out of memory then the
system is doomed anyway. Cleanup up a couple of kilobytes wont make a
difference at all
Thanks,
tglx
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-02-11 12:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-10 7:27 [PATCH] clockevents: Add error handling and rollback in tick_init_sysfs() Zhan Xusheng
2026-02-11 12:58 ` Thomas Gleixner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox