git: f90940ce6eb7 - main - vm_page: Fix handling of empty bad memory addresses file

From: Romain Tartière <romain_at_FreeBSD.org>
Date: Mon, 04 Aug 2025 03:45:04 UTC
The branch main has been updated by romain:

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

commit f90940ce6eb71df40538c35a65d77ad3093c679a
Author:     Romain Tartière <romain@FreeBSD.org>
AuthorDate: 2025-08-03 05:42:23 +0000
Commit:     Romain Tartière <romain@FreeBSD.org>
CommitDate: 2025-08-04 03:40:24 +0000

    vm_page: Fix handling of empty bad memory addresses file
    
    If a file with bad memory addresses is configured but that file is
    empty (0 lines, 0 bytes), when loading it we end up returning an end
    pointer that is just _before_ the start of the (empty) file content.
    
    Adjust the code to make it clear what pre-condition are required to set
    the *list / *end pointers correctly, and explicitly set them to NULL
    when they are not matched.
    
    Reported by:    marklmi@yahoo.com
    Reviewed by:    kib
    MFC after:      1 week
    Differential Revision:  https://reviews.freebsd.org/D51717
---
 sys/vm/vm_page.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/sys/vm/vm_page.c b/sys/vm/vm_page.c
index b239a6ffb4ce..d3772af3c284 100644
--- a/sys/vm/vm_page.c
+++ b/sys/vm/vm_page.c
@@ -394,11 +394,15 @@ vm_page_blacklist_load(char **list, char **end)
 		ptr = preload_fetch_addr(mod);
 		len = preload_fetch_size(mod);
         }
-	*list = ptr;
-	if (ptr != NULL)
+
+	if (ptr != NULL && len > 0) {
+		*list = ptr;
 		*end = ptr + len - 1;
-	else
+	} else {
+		*list = NULL;
 		*end = NULL;
+	}
+
 	return;
 }