The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: "Jackie Liu" <liu.yun@linux.dev>
To: "Andrew Morton" <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] lib: cpu_rmap: reject zero-sized maps
Date: Sun, 19 Jul 2026 03:36:37 +0000	[thread overview]
Message-ID: <9df338a30f3fb369681f826fc92c850e50c406e1@linux.dev> (raw)
In-Reply-To: <20260717215642.9e4b74a29e0b3afa2ee45938@linux-foundation.org>

2026年7月18日 12:56, "Andrew Morton" <akpm@linux-foundation.org mailto:akpm@linux-foundation.org?to=%22Andrew%20Morton%22%20%3Cakpm%40linux-foundation.org%3E > 写到:


> 
> On Sat, 18 Jul 2026 12:21:55 +0800 Jackie Liu <liu.yun@linux.dev> wrote:
> 
> > 
> > From: Jackie Liu <liuyun01@kylinos.cn>
> >  
> >  alloc_cpu_rmap() assigns an object index to each possible CPU using
> >  cpu % size. Passing zero therefore triggers a divide error instead of
> >  reporting that the map cannot be allocated.
> > 
> Is there any situation in which this is known to trigger?
> 
> > 
> > Reject zero along with sizes that do not fit in the u16 map indices.
> > 
> If passing zero is a caller bug then a divide-by-zero exception is a
> fine way of reporting it. So I'm not seeing a need to make any change
> here.
>

Thanks. I rechecked all in-tree callers and couldn't find a path which
can legitimately pass zero.  The size is either explicitly checked or
derived from successfully allocated IRQ/RX queue counts, whose minimum
is one.

So zero would indeed indicate a caller bug.  Please disregard this
patch.

      reply	other threads:[~2026-07-19  3:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-18  4:21 [PATCH] lib: cpu_rmap: reject zero-sized maps Jackie Liu
2026-07-18  4:56 ` Andrew Morton
2026-07-19  3:36   ` Jackie Liu [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=9df338a30f3fb369681f826fc92c850e50c406e1@linux.dev \
    --to=liu.yun@linux.dev \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    /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