git: 57a7f61b13c3 - stable/14 - kerneldump: fix incorrect SETSIZE to BIT_COPY_STORE_REL when livedump

From: Ka Ho Ng <khng_at_FreeBSD.org>
Date: Sat, 30 Nov 2024 06:54:07 UTC
The branch stable/14 has been updated by khng:

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

commit 57a7f61b13c3c9c171fa791466dce4df704629c0
Author:     Ka Ho Ng <khng@FreeBSD.org>
AuthorDate: 2024-11-23 16:35:07 +0000
Commit:     Ka Ho Ng <khng@FreeBSD.org>
CommitDate: 2024-11-30 06:53:49 +0000

    kerneldump: fix incorrect SETSIZE to BIT_COPY_STORE_REL when livedump
    
    Also replace malloc/free with BITSET_ALLOC/BITSET_FREE macros.
    
    Sponsored by:   Juniper Networks, Inc.
    MFC after:      1 week
    Reviewed by:    markj
    Differential Revision:  https://reviews.freebsd.org/D47708
    
    (cherry picked from commit 9ad8116b54616a5e8cbcdd2e1432893dce0c608c)
---
 sys/kern/kern_dump.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/sys/kern/kern_dump.c b/sys/kern/kern_dump.c
index 3afaee9acb7e..a3ca716b2861 100644
--- a/sys/kern/kern_dump.c
+++ b/sys/kern/kern_dump.c
@@ -466,7 +466,6 @@ minidumpsys(struct dumperinfo *di, bool livedump)
 	struct minidumpstate state;
 	struct msgbuf mb_copy;
 	char *msg_ptr;
-	size_t sz;
 	int error;
 
 	if (livedump) {
@@ -511,9 +510,10 @@ minidumpsys(struct dumperinfo *di, bool livedump)
 		msgbuf_duplicate(msgbufp, &mb_copy, msg_ptr);
 		state.msgbufp = &mb_copy;
 
-		sz = BITSET_SIZE(vm_page_dump_pages);
-		state.dump_bitset = malloc(sz, M_TEMP, M_WAITOK);
-		BIT_COPY_STORE_REL(sz, vm_page_dump, state.dump_bitset);
+		state.dump_bitset = BITSET_ALLOC(vm_page_dump_pages, M_TEMP,
+		    M_WAITOK);
+		BIT_COPY_STORE_REL(vm_page_dump_pages, vm_page_dump,
+		    state.dump_bitset);
 	} else {
 		KASSERT(dumping, ("minidump invoked outside of doadump()"));
 
@@ -525,7 +525,7 @@ minidumpsys(struct dumperinfo *di, bool livedump)
 	error = cpu_minidumpsys(di, &state);
 	if (livedump) {
 		free(msg_ptr, M_TEMP);
-		free(state.dump_bitset, M_TEMP);
+		BITSET_FREE(state.dump_bitset, M_TEMP);
 	}
 
 	return (error);