[<prev] [next>] [day] [month] [year] [list]
Message-ID: <tencent_2376993D9FC06A3616A4F981B3DE1C599607@qq.com>
Date: Wed, 15 Oct 2025 14:17:53 +0800
From: Haofeng Li <920484857@...com>
To: John Stultz <jstultz@...gle.com>,
Thomas Gleixner <tglx@...utronix.de>
Cc: linux-kernel@...r.kernel.org,
Haofeng Li <13266079573@....com>,
Haofeng Li <lihaofeng@...inos.cn>
Subject: [PATCH] time: fix aux clocks sysfs initialization loop bound
From: Haofeng Li <lihaofeng@...inos.cn>
The loop in tk_aux_sysfs_init() uses `i <= MAX_AUX_CLOCKS` as the
termination condition, which results in 9 iterations (i=0 to 8)
when MAX_AUX_CLOCKS is defined as 8. However, the kernel is designed
to support only up to 8 auxiliary clocks.
This off-by-one error causes the creation of a 9th sysfs entry
that exceeds the intended auxiliary clock range.
Fix the loop bound to use `i < MAX_AUX_CLOCKS` to ensure exactly
8 auxiliary clock entries are created, matching the design
specification.
Signed-off-by: Haofeng Li <lihaofeng@...inos.cn>
---
kernel/time/timekeeping.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index b6974fce800c..3a4d3b2e3f74 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -3070,7 +3070,7 @@ static int __init tk_aux_sysfs_init(void)
return -ENOMEM;
}
- for (int i = 0; i <= MAX_AUX_CLOCKS; i++) {
+ for (int i = 0; i < MAX_AUX_CLOCKS; i++) {
char id[2] = { [0] = '0' + i, };
struct kobject *clk = kobject_create_and_add(id, auxo);
--
2.25.1
Powered by blists - more mailing lists