Skip to content

Commit eead13d

Browse files
committed
KVM: selftests: Assert that __vm_get_stat() actually finds a stat
Fail the test if it attempts to read a stat that doesn't exist, e.g. due to a typo (hooray, strings), or because the test tried to get a stat for the wrong scope. As is, there's no indiciation of failure and @DaTa is left untouched, e.g. holds '0' or random stack data in most cases. Fixes: 8448ec5 ("KVM: selftests: Add NX huge pages test") Link: https://lore.kernel.org/r/[email protected] [sean: fixup spelling mistake, courtesy of Colin Ian King] Signed-off-by: Sean Christopherson <[email protected]>
1 parent f7f232a commit eead13d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

tools/testing/selftests/kvm/lib/kvm_util.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2238,9 +2238,10 @@ void __vm_get_stat(struct kvm_vm *vm, const char *stat_name, uint64_t *data,
22382238

22392239
read_stat_data(vm->stats_fd, &vm->stats_header, desc,
22402240
data, max_elements);
2241-
2242-
break;
2241+
return;
22432242
}
2243+
2244+
TEST_FAIL("Unable to find stat '%s'", stat_name);
22442245
}
22452246

22462247
__weak void kvm_arch_vm_post_create(struct kvm_vm *vm)

0 commit comments

Comments
 (0)