Files
linux/tools
longlong yan 9922d4ced6 selftests/mm/pagemap_ioctl: fix missing NULL checks after calloc()
The pagemap_ioctl selftest allocates memory via calloc() in several places
but does not check the return values.  If calloc() fails, the subsequent
code will dereference a NULL pointer and crash.

Additionally, in sanity_tests(), the calloc() failure check incorrectly
uses MAP_FAILED (the mmap() error constant) instead of NULL.  Since
calloc() returns NULL on failure, the check never triggers and a failed
allocation goes undetected.

Add NULL checks after each calloc() call, and fix the wrong error constant
in sanity_tests().  Use ksft_exit_fail_msg() consistent with the existing
error handling pattern in the file.

Link: https://lore.kernel.org/20260721063611.342-1-yanlonglong@kylinos.cn
Signed-off-by: longlong yan <yanlonglong@kylinos.cn>
Acked-by: David Hildenbrand (Arm) <david@kernel.org>
Reviewed-by: SJ Park <sj@kernel.org>
Cc: Shuah Khan <shuah@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2026-08-06 18:57:21 -07:00
..
2026-04-14 04:43:26 +00:00
2026-07-08 10:38:18 +02:00