mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-07-22 02:17:36 -04:00
selftests/mm: check file initialization writes in split_huge_page_test
create_pagecache_thp_and_fd() fills the backing file for the pagecache THP tests using repeated write() calls, but the return value is never checked. If a write fails or completes only partially, the test may continue with an incompletely initialized file and produce misleading results. Check the result of write() and fail the test if the expected number of bytes was not written. [akpm@linux-foundation.org: remove unneeded local, per David] Link: https://lore.kernel.org/da82de92-29d8-457c-9f65-40fc4900b922@kernel.org Link: https://lore.kernel.org/20260512074924.27721-1-agarwal.vineet2006@gmail.com Signed-off-by: Vineet Agarwal <agarwal.vineet2006@gmail.com> Acked-by: David Hildenbrand (Arm) <david@kernel.org> Cc: Lorenzo Stoakes <ljs@kernel.org> Cc: Wei Yang <richard.weiyang@gmail.com> Cc: Vineet Agarwal <agarwal.vineet2006@gmail.com> Cc: Lorenzo Stoakes <ljs@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
committed by
Andrew Morton
parent
14d1948fa2
commit
6d544529f9
@@ -609,9 +609,13 @@ static int create_pagecache_thp_and_fd(const char *testfile, size_t fd_size,
|
||||
assert(fd_size % sizeof(buf) == 0);
|
||||
for (i = 0; i < sizeof(buf); i++)
|
||||
buf[i] = (unsigned char)i;
|
||||
for (i = 0; i < fd_size; i += sizeof(buf))
|
||||
write(*fd, buf, sizeof(buf));
|
||||
|
||||
for (i = 0; i < fd_size; i += sizeof(buf)) {
|
||||
if (write(*fd, buf, sizeof(buf)) != sizeof(buf)) {
|
||||
ksft_perror("write testfile");
|
||||
close(*fd);
|
||||
goto err_out_unlink;
|
||||
}
|
||||
}
|
||||
close(*fd);
|
||||
sync();
|
||||
*fd = open("/proc/sys/vm/drop_caches", O_WRONLY);
|
||||
|
||||
Reference in New Issue
Block a user