timers/migration: Fix memory leak in tmigr_setup_groups() error path

When the WARN_ON_ONCE(i >= tmigr_hierarchy_levels) assertion triggers,
the function returns -EINVAL without freeing the 'stack' memory allocated
via kzalloc_objs() at the beginning of the function.

Add kfree(stack) before returning to prevent the memory leak.

Fixes: 6c181b5667 ("timers/migration: Convert "while" loops to use "for"")
Signed-off-by: Malaya Kumar Rout <malayarout91@gmail.com>
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Link: https://patch.msgid.link/20260704085533.87098-1-malayarout91@gmail.com
This commit is contained in:
Malaya Kumar Rout
2026-07-07 23:26:58 +02:00
committed by Thomas Gleixner
parent f2eee7e31c
commit eddfded419
+3 -1
View File
@@ -1847,8 +1847,10 @@ static int tmigr_setup_groups(struct tmigr_hierarchy *hier, unsigned int cpu,
}
/* Assert single root without parent */
if (WARN_ON_ONCE(i >= tmigr_hierarchy_levels))
if (WARN_ON_ONCE(i >= tmigr_hierarchy_levels)) {
kfree(stack);
return -EINVAL;
}
for (; i >= start_lvl; i--) {
group = stack[i];