[PATCH 1/5] lib/group_cpus: Let group_cpu_evenly() return the number of initialized masks

Chaitanya Kulkarni chaitanyak at nvidia.com
Tue Jun 24 21:34:40 PDT 2025


On 6/17/25 06:43, Daniel Wagner wrote:
> group_cpu_evenly() might have allocated less groups then requested:
>
> group_cpu_evenly()
>    __group_cpus_evenly()
>      alloc_nodes_groups()
>        # allocated total groups may be less than numgrps when
>        # active total CPU number is less then numgrps
>
> In this case, the caller will do an out of bound access because the
> caller assumes the masks returned has numgrps.
>
> Return the number of groups created so the caller can limit the access
> range accordingly.
>
> Acked-by: Thomas Gleixner<tglx at linutronix.de>
> Reviewed-by: Hannes Reinecke<hare at suse.de>
> Reviewed-by: Ming Lei<ming.lei at redhat.com>
> Signed-off-by: Daniel Wagner<wagi at kernel.org>
> ---

Looks good.

Reviewed-by: Chaitanya Kulkarni <kch at nvidia.com>

-ck




More information about the Linux-nvme mailing list