Re: [PATCH] lib: cpu_rmap: reject zero-sized maps
From: Jackie Liu
Date: Sat Jul 18 2026 - 23:36:50 EST
2026年7月18日 12:56, "Andrew Morton" <akpm@xxxxxxxxxxxxxxxxxxxx mailto:akpm@xxxxxxxxxxxxxxxxxxxx?to=%22Andrew%20Morton%22%20%3Cakpm%40linux-foundation.org%3E > 写到:
>
> On Sat, 18 Jul 2026 12:21:55 +0800 Jackie Liu <liu.yun@xxxxxxxxx> wrote:
>
> >
> > From: Jackie Liu <liuyun01@xxxxxxxxxx>
> >
> > 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.