mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-28 15:47:16 -04:00
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>