public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] timers/migration: Ensure proper resource cleanup on error in tmigr_init
@ 2026-02-04  8:50 Zhan Xusheng
  2026-02-04 15:08 ` Thomas Gleixner
  0 siblings, 1 reply; 6+ messages in thread
From: Zhan Xusheng @ 2026-02-04  8:50 UTC (permalink / raw)
  To: Anna-Maria Behnsen; +Cc: linux-kernel, Zhan Xusheng

Free resources allocated by zalloc_cpumask_var and kcalloc on failure.

Signed-off-by: Zhan Xusheng <zhanxusheng@xiaomi.com>
---
 kernel/time/timer_migration.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/kernel/time/timer_migration.c b/kernel/time/timer_migration.c
index 18dda1aa782d..c2b3aa6946c1 100644
--- a/kernel/time/timer_migration.c
+++ b/kernel/time/timer_migration.c
@@ -1994,7 +1994,7 @@ static int __init tmigr_init(void)
 
 	tmigr_level_list = kcalloc(tmigr_hierarchy_levels, sizeof(struct list_head), GFP_KERNEL);
 	if (!tmigr_level_list)
-		goto err;
+		goto err_free_cpumask;
 
 	for (i = 0; i < tmigr_hierarchy_levels; i++)
 		INIT_LIST_HEAD(&tmigr_level_list[i]);
@@ -2007,15 +2007,21 @@ static int __init tmigr_init(void)
 	ret = cpuhp_setup_state(CPUHP_TMIGR_PREPARE, "tmigr:prepare",
 				tmigr_cpu_prepare, NULL);
 	if (ret)
-		goto err;
+		goto err_free_level_list;
 
 	ret = cpuhp_setup_state(CPUHP_AP_TMIGR_ONLINE, "tmigr:online",
 				tmigr_set_cpu_available, tmigr_clear_cpu_available);
 	if (ret)
-		goto err;
+		goto err_free_level_list;
 
 	return 0;
 
+err_free_level_list:
+	kfree(tmigr_level_list);
+
+err_free_cpumask:
+	free_cpumask_var(tmigr_available_cpumask);
+
 err:
 	pr_err("Timer migration setup failed\n");
 	return ret;
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-02-11 15:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-04  8:50 [PATCH] timers/migration: Ensure proper resource cleanup on error in tmigr_init Zhan Xusheng
2026-02-04 15:08 ` Thomas Gleixner
2026-02-05  2:45   ` [PATCH v2] " Zhan Xusheng
2026-02-05  7:27     ` Thomas Gleixner
2026-02-05  7:35       ` [PATCH v3] " Zhan Xusheng
2026-02-11 15:40         ` Frederic Weisbecker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox