Skip to content

Commit e9da6f0

Browse files
Dongli Zhangsean-jc
authored andcommitted
KVM: selftests: Explicitly close guest_memfd files in some gmem tests
Explicitly close() guest_memfd files in various guest_memfd and private_mem_conversions tests, there's no reason to keep the files open until the test exits. Fixes: 8a89efd ("KVM: selftests: Add basic selftest for guest_memfd()") Fixes: 43f623f ("KVM: selftests: Add x86-only selftest for private memory conversions") Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com> Link: https://lore.kernel.org/r/20240227015716.27284-1-dongli.zhang@oracle.com [sean: massage changelog] Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent 40e09b3 commit e9da6f0

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

tools/testing/selftests/kvm/guest_memfd_test.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,9 @@ static void test_create_guest_memfd_multiple(struct kvm_vm *vm)
167167
TEST_ASSERT(ret != -1, "memfd fstat should succeed");
168168
TEST_ASSERT(st1.st_size == 4096, "first memfd st_size should still match requested size");
169169
TEST_ASSERT(st1.st_ino != st2.st_ino, "different memfd should have different inode numbers");
170+
171+
close(fd2);
172+
close(fd1);
170173
}
171174

172175
int main(int argc, char *argv[])

tools/testing/selftests/kvm/x86_64/private_mem_conversions_test.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,8 @@ static void test_mem_conversions(enum vm_mem_backing_src_type src_type, uint32_t
434434

435435
r = fallocate(memfd, FALLOC_FL_KEEP_SIZE, 0, memfd_size);
436436
TEST_ASSERT(!r, __KVM_SYSCALL_ERROR("fallocate()", r));
437+
438+
close(memfd);
437439
}
438440

439441
static void usage(const char *cmd)

0 commit comments

Comments
 (0)