quiesce_cpus(): do not overallocate generation array

Also switch to mallocarray().

Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D39981
This commit is contained in:
Konstantin Belousov 2023-05-05 23:21:38 +03:00
parent e8e7e1462e
commit ccc6b87b38

View File

@ -975,7 +975,8 @@ quiesce_cpus(cpuset_t map, const char *wmesg, int prio)
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;