Re: [PATCH v14 3/8] lib/group_cpus: Add group_mask_cpus_evenly()

From: Aaron Tomlin

Date: Wed May 20 2026 - 23:13:25 EST


On Wed, May 20, 2026 at 05:50:25PM -0400, Aaron Tomlin wrote:
> + *nummasks = min(nr_present + nr_others, numgrps);
> + return masks;
> +}

If a NUMA node has exactly zero online housekeeping CPUs, the grouping
algorithm processes zero for nr_present and nr_others. Erroneously, the
caller sees a non-NULL return value, assumes the mapping succeeded, and
executes a loop doing fatal: queue % nr_masks.

I suggest we must intercept, free the array, and return NULL. Therefore,
the caller falls back to safe default routing:

@@ -432,6 +432,10 @@ struct cpumask *group_mask_cpus_evenly(unsigned int numgrps,
return NULL;
}
*nummasks = min(nr_present + nr_others, numgrps);
+ if (*nummasks == 0) {
+ kfree(masks);
+ return NULL;
+ }
return masks;
}

--
Aaron Tomlin