The mmap test currently checks for failure by comparing the return
value of mmap() against NULL. However, mmap() indicates failure by
returning MAP_FAILED, not NULL. This means a failure would go
undetected and the test would proceed with an invalid pointer.

Update the check to compare against MAP_FAILED.

Signed-off-by: Alison Schofield <[email protected]>
---
 test/mmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test/mmap.c b/test/mmap.c
index 0a66967a25f6..98b85fe8453e 100644
--- a/test/mmap.c
+++ b/test/mmap.c
@@ -155,7 +155,7 @@ int main(int argc, char **argv)
 
        printf("> mmap mprot 0x%x flags 0x%x\n", mprot, mflags);
        p = mmap(mptr, size, mprot, mflags, fd, 0x0);
-       if (!p) {
+       if (p == MAP_FAILED) {
                perror("mmap failed");
                return EXIT_FAILURE;
        }

base-commit: 8ad90e54f0ff4f7291e7f21d44d769d10f24e2b6
-- 
2.37.3


Reply via email to