Skip to content

Commit

Permalink
KVM: selftests: fix unintentional noop test in guest_memfd_test.c
Browse files Browse the repository at this point in the history
The loop in test_create_guest_memfd_invalid() that is supposed to test
that nothing is accepted as a valid flag to KVM_CREATE_GUEST_MEMFD was
initializing `flag` as 0 instead of BIT(0). This caused the loop to
immediately exit instead of iterating over BIT(0), BIT(1), ... .

Fixes: 8a89efd ("KVM: selftests: Add basic selftest for guest_memfd()")
Signed-off-by: Patrick Roy <[email protected]>
Reviewed-by: James Gowans <[email protected]>
Reviewed-by: Muhammad Usama Anjum <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Sean Christopherson <[email protected]>
  • Loading branch information
roypat authored and sean-jc committed Nov 5, 2024
1 parent 2d0f2a6 commit 945bdae
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tools/testing/selftests/kvm/guest_memfd_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ static void test_create_guest_memfd_invalid(struct kvm_vm *vm)
size);
}

for (flag = 0; flag; flag <<= 1) {
for (flag = BIT(0); flag; flag <<= 1) {
fd = __vm_create_guest_memfd(vm, page_size, flag);
TEST_ASSERT(fd == -1 && errno == EINVAL,
"guest_memfd() with flag '0x%lx' should fail with EINVAL",
Expand Down

0 comments on commit 945bdae

Please sign in to comment.