git: b9ca790637fc - stable/13 - quiesce_cpus(): do not overallocate generation array

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Tue, 16 May 2023 04:11:00 UTC
The branch stable/13 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=b9ca790637fc25b2d2a190cd925ec2e6cb0db683

commit b9ca790637fc25b2d2a190cd925ec2e6cb0db683
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2023-05-05 20:21:38 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2023-05-16 04:03:37 +0000

    quiesce_cpus(): do not overallocate generation array
    
    (cherry picked from commit ccc6b87b3825a235991d978e43d29431e012461f)
---
 sys/kern/subr_smp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

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;