tests/tcg/i386/test-flags: Check mmap() return value
PATCH 1/1 tests/tcg/i386/test-flags: Check mmap() return value
test-flags.c calls mmap() to allocate a page but does not check whether it succeeded. If the allocation fails, the following *mprotect()* and *asm* block dereference the invalid pointer and produce a confusing failure.
Add an assertion to fail early with a clear message.
Fixes e7bbb7cb71b3 ("target/i386: introduce flags writeback mechanism")
Signed-off-by longlong yan <[email protected]>
--- tests/tcg/i386/test-flags.c | 1 + 1 file changed, 1 insertion(+)
tests/tcg/i386/test-flags.c +1 -0
@@ -21,6 +21,7 @@ int main()/* fault in the page then protect it */ addr =mmap (NULL ,4096 ,PROT_READ |PROT_WRITE ,MAP_PRIVATE |MAP_ANON ,-1 ,0 ); +assert (addr !=MAP_FAILED ); *addr =0x1234 ;mprotect (addr,4096 ,PROT_READ );
Signature · 1 line
2.43.0