summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorAnshuman <anshumantewari123@gmail.com>2026-08-19 17:44:26 +0530
committerAndrew Morton <akpm@linux-foundation.org>2026-08-24 18:43:27 -0700
commitd16e52a9ba9ed5060f97ed3191017a21b5fc25a2 (patch)
tree647f9e409ad42147064439e5d03ae760ce6a9357 /include/linux
parentf9dc428249ed962a70acf301f01eae8578449161 (diff)
selftests/mm: check stat() return value in khugepaged get_finfo()
get_finfo() calls stat() to get metadata about the target directory, but never checks the return value. On failure, stat() returns -1 and leaves path_stat unmodified, so path_stat.st_mode may contain uninitialized stack data. The code then checks S_ISDIR(path_stat.st_mode) against this potentially garbage value. This can produce a misleading "Not a directory" error when the real problem is a nonexistent or inaccessible path, or, in the worst case, the check could pass by chance on garbage data and let the function continue using an invalid path_stat for the rest of its logic. Check the return value and fail with a clear error message if stat() fails, matching the error-handling style already used for statfs() and read_file() later in the same function. Link: https://lore.kernel.org/20260819121426.49500-1-anshumantewari123@gmail.com Signed-off-by: Anshuman <anshumantewari123@gmail.com> Reviewed-by: Andrew Morton <akpm@linux-foundation.org> Reviewed-by: SJ Park <sj@kernel.org> Reviewed-by: Sarthak Sharma <sarthak.sharma@arm.com> Acked-by: David Hildenbrand (Arm) <david@kernel.org> Cc: Lorenzo Stoakes <ljs@kernel.org> Cc: Shuah Khan <shuah@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'include/linux')
0 files changed, 0 insertions, 0 deletions