timers/migration: Fix memory leak in tmigr_setup_groups()
PATCH 1/1 timers/migration: Fix memory leak in tmigr_setup_groups()
tmigr_setup_groups() allocates 'stack' via kzalloc_objs(), but in the case where WARN_ON_ONCE(i >= tmigr_hierarchy_levels) triggers, the function returns -EINVAL without freeing 'stack', causing a memory leak.
Fix this by redirecting the error path to the common 'out:' label so that 'stack' is properly freed.
Signed-off-by Zhan Xusheng <[email protected]>
--- kernel/time/timer_migration.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
kernel/time/timer_migration.c +4 -2
@@ -1804,8 +1804,10 @@ static int tmigr_setup_groups(unsigned int cpu, unsigned int node, }/* Assert single root without parent */ -if (WARN_ON_ONCE (i >= tmigr_hierarchy_levels)) -return -EINVAL ; +if (WARN_ON_ONCE (i >= tmigr_hierarchy_levels)) { + err = -EINVAL ; + goto out; + }for (; i >= start_lvl; i--) { group = stack[i];
Signature · 1 line
2.43.0