Re: [PATCH] mempolicy: fix div-by-zero in alloc_pages_bulk_weighted_interleave
From: Andrew Morton
Date: Wed Sep 02 2026 - 17:56:14 EST
On Wed, 2 Sep 2026 09:57:35 -0400 Gregory Price <gourry@xxxxxxxxxx> wrote:
> On Wed, Sep 02, 2026 at 05:04:12PM +0800, Liu Jing wrote:
> > In alloc_pages_bulk_weighted_interleave(), if the iw_table contains
> > all-zero weights for every node in the policy nodemask, weight_total
> > sums to zero. The subsequent "rem_pages / weight_total" and
> > "rem_pages % weight_total" trigger a divide-by-zero panic.
> >
>
> weights can't be zero and we just fixed the rebind race
So if the caller passes in me->weight==0 then we consider that caller
to be buggy.
In which case a div-by-zero is a perfectly acceptable way of reporting
this bug, no code changes needed,