From: Thomas Gleixner <tglx@kernel.org>
To: Zhan Xusheng <zhanxusheng1024@gmail.com>,
Anna-Maria Behnsen <anna-maria@linutronix.de>
Cc: linux-kernel@vger.kernel.org, Zhan Xusheng <zhanxusheng@xiaomi.com>
Subject: Re: [PATCH] timers/migration: Ensure proper resource cleanup on error in tmigr_init
Date: Wed, 04 Feb 2026 16:08:22 +0100 [thread overview]
Message-ID: <87sebg1r89.ffs@tglx> (raw)
In-Reply-To: <20260204085018.57764-1-zhanxusheng@xiaomi.com>
On Wed, Feb 04 2026 at 16:50, Zhan Xusheng wrote:
> 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;
Which leaves the prepare hotplug state registered ....
> 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;
next prev parent reply other threads:[~2026-02-04 15:08 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87sebg1r89.ffs@tglx \
--to=tglx@kernel.org \
--cc=anna-maria@linutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=zhanxusheng1024@gmail.com \
--cc=zhanxusheng@xiaomi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox