public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] clockevents: add a error handling in tick_broadcast_init_sysfs()
@ 2025-12-18  9:06 Haoxiang Li
  2025-12-19 10:17 ` Thomas Gleixner
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Haoxiang Li @ 2025-12-18  9:06 UTC (permalink / raw)
  To: anna-maria, frederic, tglx; +Cc: linux-kernel, Haoxiang Li, stable

If device_register() fails, call put_device() to drop
the device reference.

Fixes: 501f867064e9 ("clockevents: Provide sysfs interface")
Cc: stable@vger.kernel.org
Signed-off-by: Haoxiang Li <lihaoxiang@isrc.iscas.ac.cn>
---
 kernel/time/clockevents.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/kernel/time/clockevents.c b/kernel/time/clockevents.c
index a59bc75ab7c5..94e223cf9c74 100644
--- a/kernel/time/clockevents.c
+++ b/kernel/time/clockevents.c
@@ -733,8 +733,12 @@ static __init int tick_broadcast_init_sysfs(void)
 {
 	int err = device_register(&tick_bc_dev);
 
-	if (!err)
-		err = device_create_file(&tick_bc_dev, &dev_attr_current_device);
+	if (err) {
+		put_deivce(&tick_bc_dev);
+		return err;
+	}
+
+	err = device_create_file(&tick_bc_dev, &dev_attr_current_device);
 	return err;
 }
 #else
-- 
2.25.1


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

end of thread, other threads:[~2025-12-22  6:25 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-18  9:06 [PATCH] clockevents: add a error handling in tick_broadcast_init_sysfs() Haoxiang Li
2025-12-19 10:17 ` Thomas Gleixner
2025-12-19 13:28   ` Haoxiang Li
2025-12-20 14:59 ` kernel test robot
2025-12-20 15:33 ` kernel test robot
2025-12-20 21:34 ` kernel test robot
2025-12-22  6:24 ` kernel test robot

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