linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Dennis Zhou <dennis@kernel.org>
To: Peng Fan <peng.fan@nxp.com>
Cc: "dennis@kernel.org" <dennis@kernel.org>,
	"tj@kernel.org" <tj@kernel.org>, "cl@linux.com" <cl@linux.com>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"van.freenix@gmail.com" <van.freenix@gmail.com>
Subject: Re: [RFC] percpu: use nr_groups as check condition
Date: Sat, 23 Feb 2019 17:46:22 -0500	[thread overview]
Message-ID: <20190223224622.GA31069@dennisz-mbp.dhcp.thefacebook.com> (raw)
In-Reply-To: <20190220134353.24456-1-peng.fan@nxp.com>

Hi Peng,

On Wed, Feb 20, 2019 at 01:32:55PM +0000, Peng Fan wrote:
> group_cnt array is defined with NR_CPUS entries, but normally
> nr_groups will not reach up to NR_CPUS. So there is no issue
> to the current code.
> 
> Checking other parts of pcpu_build_alloc_info, use nr_groups as
> check condition, so make it consistent to use 'group < nr_groups'
> as for loop check. In case we do have nr_groups equals with NR_CPUS,
> we could also avoid memory access out of bounds.
> 
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
>  mm/percpu.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/mm/percpu.c b/mm/percpu.c
> index db86282fd024..c5c750781628 100644
> --- a/mm/percpu.c
> +++ b/mm/percpu.c
> @@ -2384,7 +2384,7 @@ static struct pcpu_alloc_info * __init pcpu_build_alloc_info(
>  	ai->atom_size = atom_size;
>  	ai->alloc_size = alloc_size;
>  
> -	for (group = 0, unit = 0; group_cnt[group]; group++) {
> +	for (group = 0, unit = 0; group < nr_groups; group++) {
>  		struct pcpu_group_info *gi = &ai->groups[group];
>  
>  		/*
> -- 
> 2.16.4
> 

This seems right to me. It is quite the edge case though. I've queued
this for 5.1.

Thanks,
Dennis


      reply	other threads:[~2019-02-23 22:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-20 13:32 Peng Fan
2019-02-23 22:46 ` Dennis Zhou [this message]

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=20190223224622.GA31069@dennisz-mbp.dhcp.thefacebook.com \
    --to=dennis@kernel.org \
    --cc=cl@linux.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=peng.fan@nxp.com \
    --cc=tj@kernel.org \
    --cc=van.freenix@gmail.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