From 13cb96d1e36c9581a1f8f2601f5383756829d834 Mon Sep 17 00:00:00 2001 From: huangshuhua Date: Mon, 30 Jun 2025 09:58:36 +0800 Subject: [PATCH] posix/mmap: validate addr non-null before alignment check --- cpukit/posix/src/mmap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cpukit/posix/src/mmap.c b/cpukit/posix/src/mmap.c index 7e7f6f8bdd..91d7780ea8 100644 --- a/cpukit/posix/src/mmap.c +++ b/cpukit/posix/src/mmap.c @@ -141,11 +141,11 @@ void *mmap( /* Check for illegal addresses. Watch out for address wrap. */ if ( map_fixed ) { - if ((uintptr_t)addr & PAGE_MASK) { + if ( addr == NULL ) { errno = EINVAL; return MAP_FAILED; } - if ( addr == NULL ) { + if ((uintptr_t)addr & PAGE_MASK) { errno = EINVAL; return MAP_FAILED; }