* [PATCH] timers/migration: Fix memory leak in tmigr_setup_groups() error path
@ 2026-07-04 8:55 Malaya Kumar Rout
2026-07-07 21:32 ` [tip: timers/core] " tip-bot2 for Malaya Kumar Rout
0 siblings, 1 reply; 2+ messages in thread
From: Malaya Kumar Rout @ 2026-07-04 8:55 UTC (permalink / raw)
To: linux-kernel, tglx
Cc: mrout, skhan, me, Malaya Kumar Rout, Anna-Maria Behnsen,
Frederic Weisbecker
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: 6c181b5667ee ("timers/migration: Convert "while" loops to use "for"")
Signed-off-by: Malaya Kumar Rout <malayarout91@gmail.com>
---
kernel/time/timer_migration.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/kernel/time/timer_migration.c b/kernel/time/timer_migration.c
index 806c23cf71fc..d2654abfdef7 100644
--- a/kernel/time/timer_migration.c
+++ b/kernel/time/timer_migration.c
@@ -1847,9 +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];
--
2.54.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* [tip: timers/core] timers/migration: Fix memory leak in tmigr_setup_groups() error path
2026-07-04 8:55 [PATCH] timers/migration: Fix memory leak in tmigr_setup_groups() error path Malaya Kumar Rout
@ 2026-07-07 21:32 ` tip-bot2 for Malaya Kumar Rout
0 siblings, 0 replies; 2+ messages in thread
From: tip-bot2 for Malaya Kumar Rout @ 2026-07-07 21:32 UTC (permalink / raw)
To: linux-tip-commits; +Cc: Malaya Kumar Rout, Thomas Gleixner, x86, linux-kernel
The following commit has been merged into the timers/core branch of tip:
Commit-ID: eddfded4196542deda7cb2da3d7ebef83f7ccfa4
Gitweb: https://git.kernel.org/tip/eddfded4196542deda7cb2da3d7ebef83f7ccfa4
Author: Malaya Kumar Rout <malayarout91@gmail.com>
AuthorDate: Sat, 04 Jul 2026 14:25:33 +05:30
Committer: Thomas Gleixner <tglx@kernel.org>
CommitterDate: Tue, 07 Jul 2026 23:26:58 +02:00
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: 6c181b5667ee ("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
---
kernel/time/timer_migration.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/kernel/time/timer_migration.c b/kernel/time/timer_migration.c
index 806c23c..059d433 100644
--- a/kernel/time/timer_migration.c
+++ b/kernel/time/timer_migration.c
@@ -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];
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-07-07 21:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-04 8:55 [PATCH] timers/migration: Fix memory leak in tmigr_setup_groups() error path Malaya Kumar Rout
2026-07-07 21:32 ` [tip: timers/core] " tip-bot2 for Malaya Kumar Rout
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®