]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
timekeeping: Fix aux clocks sysfs initialization loop bound
authorHaofeng Li <lihaofeng@kylinos.cn>
Wed, 15 Oct 2025 06:17:53 +0000 (14:17 +0800)
committerThomas Gleixner <tglx@linutronix.de>
Mon, 20 Oct 2025 17:56:12 +0000 (19:56 +0200)
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.

Fixes: 7b95663a3d96 ("timekeeping: Provide interface to control auxiliary clocks")
Signed-off-by: Haofeng Li <lihaofeng@kylinos.cn>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://patch.msgid.link/tencent_2376993D9FC06A3616A4F981B3DE1C599607@qq.com
kernel/time/timekeeping.c

index b6974fce800cd8b8a9d66b3663f3c91fb338a751..3a4d3b2e3f74092b2cd36b9e2b7fe2fce970aed6 100644 (file)
@@ -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);