Skip to content

Commit d7ad05c

Browse files
SupremacistLeviKAGA-KOKO
authored andcommitted
timers/migration: Prevent out of bounds access on failure
When tmigr_setup_groups() fails the level 0 group allocation, then the cleanup derefences index -1 of the local stack array. Prevent this by checking the loop condition first. Fixes: 7ee9887 ("timers: Implement the hierarchical pull model") Signed-off-by: Levi Yun <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Reviewed-by: Anna-Maria Behnsen <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent dd5a440 commit d7ad05c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

kernel/time/timer_migration.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1596,7 +1596,7 @@ static int tmigr_setup_groups(unsigned int cpu, unsigned int node)
15961596

15971597
} while (i < tmigr_hierarchy_levels);
15981598

1599-
do {
1599+
while (i > 0) {
16001600
group = stack[--i];
16011601

16021602
if (err < 0) {
@@ -1645,7 +1645,7 @@ static int tmigr_setup_groups(unsigned int cpu, unsigned int node)
16451645
tmigr_connect_child_parent(child, group);
16461646
}
16471647
}
1648-
} while (i > 0);
1648+
}
16491649

16501650
kfree(stack);
16511651

0 commit comments

Comments
 (0)