aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Belousov <kib@FreeBSD.org>2023-05-05 20:21:38 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2023-05-16 04:03:37 +0000
commitb9ca790637fc25b2d2a190cd925ec2e6cb0db683 (patch)
treec488861715d794cb824eab1f6f53bc676a9d4660
parent764664aaa5d547b58db321c40162eced7fd4da7a (diff)
quiesce_cpus(): do not overallocate generation array
(cherry picked from commit ccc6b87b3825a235991d978e43d29431e012461f)
-rw-r--r--sys/kern/subr_smp.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/sys/kern/subr_smp.c b/sys/kern/subr_smp.c
index 7b250aeccc56..401d54277669 100644
--- a/sys/kern/subr_smp.c
+++ b/sys/kern/subr_smp.c
@@ -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;