git: e6901a29bc43 - main - kvm_close(3): Check kd->sparse_map != NULL before munmap

From: Ashish SHUKLA <ashish_at_FreeBSD.org>
Date: Sun, 16 Oct 2022 16:51:01 UTC
The branch main has been updated by ashish (ports committer):

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

commit e6901a29bc4345f12e9c85426cc2be81045020a6
Author:     Ashish SHUKLA <ashish@FreeBSD.org>
AuthorDate: 2022-08-30 08:18:51 +0000
Commit:     Ashish SHUKLA <ashish@FreeBSD.org>
CommitDate: 2022-10-16 16:49:16 +0000

    kvm_close(3): Check kd->sparse_map != NULL before munmap
    
    PR:             266113
    Reviewed by:    markj
---
 lib/libkvm/kvm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/libkvm/kvm.c b/lib/libkvm/kvm.c
index b98f2f25e619..4b886171a7d6 100644
--- a/lib/libkvm/kvm.c
+++ b/lib/libkvm/kvm.c
@@ -303,7 +303,7 @@ kvm_close(kvm_t *kd)
 		free(kd->pt_map);
 	if (kd->page_map != NULL)
 		free(kd->page_map);
-	if (kd->sparse_map != MAP_FAILED)
+	if (kd->sparse_map != MAP_FAILED && kd->sparse_map != NULL)
 		munmap(kd->sparse_map, kd->pt_sparse_size);
 	free((void *)kd);