]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
selftests/perf_events: fix mmap() error check in sigtrap_threads
authorHongfu Li <lihongfu@kylinos.cn>
Wed, 13 May 2026 02:58:38 +0000 (10:58 +0800)
committerAndrew Morton <akpm@linux-foundation.org>
Fri, 29 May 2026 04:24:49 +0000 (21:24 -0700)
commit2f5026b8d4fe34601d692ae7f7cd27367e002266
treeec14241a8d24fd1917ad7c69d2cc50b87f98453a
parent1c56b9cb489e7aa820dd61860e3dd892bdebe80c
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>
tools/testing/selftests/perf_events/watermark_signal.c