[3.13] gh-144194: Fix mmap failure check in perf_jit_trampoline.c (#143713) (#144304)

gh-144194: Fix mmap failure check in perf_jit_trampoline.c (#143713)

mmap() returns MAP_FAILED ((void*)-1) on error, not NULL. The current
check never detects mmap failures, so jitdump initialization proceeds
even when the memory mapping fails.

(cherry picked from commit 8fe8a94a7c)

Co-authored-by: stratakis <cstratak@redhat.com>
This commit is contained in:
Victor Stinner
2026-01-28 15:15:39 +01:00
committed by GitHub
parent bc92e7878f
commit e752ea9eb9
2 changed files with 3 additions and 1 deletions
+2 -1
View File
@@ -1053,7 +1053,8 @@ static void* perf_map_jit_init(void) {
0 // Offset 0 (first page)
);
if (perf_jit_map_state.mapped_buffer == NULL) {
if (perf_jit_map_state.mapped_buffer == MAP_FAILED) {
perf_jit_map_state.mapped_buffer = NULL;
close(fd);
return NULL; // Memory mapping failed
}