public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Frederic Weisbecker <frederic@kernel.org>
To: Levi Yun <ppbuk5246@gmail.com>
Cc: anna-maria@linutronix.de, tglx@linutronix.de,
	Markus.Elfring@web.de, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] time/timgr: Fix wrong reference when level 0 group allocation failed
Date: Mon, 6 May 2024 12:10:18 +0200	[thread overview]
Message-ID: <ZjisiuqiR9p76YcJ@localhost.localdomain> (raw)
In-Reply-To: <20240506041059.86877-1-ppbuk5246@gmail.com>

Le Mon, May 06, 2024 at 05:10:59AM +0100, Levi Yun a écrit :
> When tmigr_setup_groups() failed level 0 group allocation,
> wrong reference happens on local stack array while intializing timer hierarchy.
> 
> To prevent this, Check loop condition first before initializing timer hierarchy.
> 
> Fixes: 7ee988770326 ("timers: Implement the hierarchical pull model")
> Signed-off-by: Levi Yun <ppbuk5246@gmail.com>
> ---
> v3:
>     - Fix typo.
> 
> v2:
> 	- Modify commit message.
> 
>  kernel/time/timer_migration.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/kernel/time/timer_migration.c b/kernel/time/timer_migration.c
> index ccba875d2234..84413114db5c 100644
> --- a/kernel/time/timer_migration.c
> +++ b/kernel/time/timer_migration.c
> @@ -1596,7 +1596,7 @@ static int tmigr_setup_groups(unsigned int cpu, unsigned int node)
> 
>  	} while (i < tmigr_hierarchy_levels);
> 
> -	do {
> +	while (i > 0) {
>  		group = stack[--i];
> 
>  		if (err < 0) {
> @@ -1645,7 +1645,7 @@ static int tmigr_setup_groups(unsigned int cpu, unsigned int node)
>  				tmigr_connect_child_parent(child, group);
>  			}
>  		}
> -	} while (i > 0);
> +	}

Looks good to me. But let's wait for Anna-Maria's second look. The group setup
is not my favourite area...

Thanks.

> 
>  	kfree(stack);
> 
> --
> 2.41.0

  reply	other threads:[~2024-05-06 10:10 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-01 19:51 [PATCH] time/timgr: Fix wrong reference when level 0 group allocation failed Levi Yun
2024-05-04  4:47 ` Yun Levi
2024-05-04 10:09 ` Markus Elfring
2024-05-05  8:57 ` [PATCH RESEND] " Levi Yun
2024-05-05 10:23   ` Markus Elfring
2024-05-05 10:55     ` Yun Levi
2024-05-05 10:54   ` [PATCH v2] " Levi Yun
2024-05-05 17:07     ` [v2] " Markus Elfring
2024-05-06  4:10   ` [PATCH v3] " Levi Yun
2024-05-06 10:10     ` Frederic Weisbecker [this message]
2024-05-08  6:16       ` Anna-Maria Behnsen
2024-05-08  6:38         ` [v3] " Markus Elfring
2024-05-08  9:45     ` [tip: timers/urgent] timers/migration: Prevent out of bounds access on failure tip-bot2 for Levi Yun
2024-05-08  9:57       ` Andy Shevchenko

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=ZjisiuqiR9p76YcJ@localhost.localdomain \
    --to=frederic@kernel.org \
    --cc=Markus.Elfring@web.de \
    --cc=anna-maria@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ppbuk5246@gmail.com \
    --cc=tglx@linutronix.de \
    /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