diff --git a/sys/kern/subr_smp.c b/sys/kern/subr_smp.c --- a/sys/kern/subr_smp.c +++ b/sys/kern/subr_smp.c @@ -975,7 +975,8 @@ error = 0; if ((prio & PDROP) == 0) { - gen = malloc(sizeof(u_int) * MAXCPU, M_TEMP, M_WAITOK); + gen = mallocarray(sizeof(u_int), mp_maxid + 1, M_TEMP, + M_WAITOK); for (cpu = 0; cpu <= mp_maxid; cpu++) { if (!CPU_ISSET(cpu, &map) || CPU_ABSENT(cpu)) continue;