Skip to content

Commit 39a9ed0

Browse files
Haofeng LiKAGA-KOKO
authored andcommitted
timekeeping: Fix aux clocks sysfs initialization loop bound
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: 7b95663 ("timekeeping: Provide interface to control auxiliary clocks") Signed-off-by: Haofeng Li <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Link: https://patch.msgid.link/[email protected]
1 parent 211ddde commit 39a9ed0

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

kernel/time/timekeeping.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3070,7 +3070,7 @@ static int __init tk_aux_sysfs_init(void)
30703070
return -ENOMEM;
30713071
}
30723072

3073-
for (int i = 0; i <= MAX_AUX_CLOCKS; i++) {
3073+
for (int i = 0; i < MAX_AUX_CLOCKS; i++) {
30743074
char id[2] = { [0] = '0' + i, };
30753075
struct kobject *clk = kobject_create_and_add(id, auxo);
30763076

0 commit comments

Comments
 (0)