git: ccc6b87b3825 - main - quiesce_cpus(): do not overallocate generation array
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 09 May 2023 15:30:14 UTC
The branch main has been updated by kib:
URL: https://cgit.FreeBSD.org/src/commit/?id=ccc6b87b3825a235991d978e43d29431e012461f
commit ccc6b87b3825a235991d978e43d29431e012461f
Author: Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2023-05-05 20:21:38 +0000
Commit: Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2023-05-09 15:30:07 +0000
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
---
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 656c945fe8c2..745b1554371e 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;