Re: [PATCH] lib: cpu_rmap: reject zero-sized maps

From: Andrew Morton

Date: Sat Jul 18 2026 - 00:57:30 EST


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.