linux/tools/testing/selftests/perf_events
Hongfu Li 2f5026b8d4 selftests/perf_events: fix mmap() error check in sigtrap_threads
In sigtrap_threads(), the return value of mmap() is checked against NULL. 
mmap() returns MAP_FAILED, which is (void *)-1, not NULL, when it fails. 
Since MAP_FAILED is non-zero and non-NULL, the condition "p == NULL" will
never be true on failure, causing the program to proceed with an invalid
pointer and segfault if mmap() actually fails under memory pressure.

Link: https://lore.kernel.org/20260513025838.594945-1-lihongfu@kylinos.cn
Signed-off-by: Hongfu Li <lihongfu@kylinos.cn>
Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Mickael Salaun <mic@digikod.net>
Cc: SeongJae Park <sj@kernel.org>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Wei Yang <richard.weiyang@gmail.com>
Cc: Kyle Huey <khuey@kylehuey.com>
Cc: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2026-05-28 21:24:49 -07:00
..
.gitignore selftests/perf_events: Add a mmap() correctness test 2025-08-05 21:55:29 +02:00
config
Makefile selftests/perf_events: Add a mmap() correctness test 2025-08-05 21:55:29 +02:00
mmap.c selftests: complete kselftest include centralization 2025-11-27 14:24:31 -08:00
remove_on_exec.c selftests: complete kselftest include centralization 2025-11-27 14:24:31 -08:00
settings
sigtrap_threads.c selftests: complete kselftest include centralization 2025-11-27 14:24:31 -08:00
watermark_signal.c selftests/perf_events: fix mmap() error check in sigtrap_threads 2026-05-28 21:24:49 -07:00