selftests: KVM: Check stat name before other fields
authorOliver Upton <oupton@google.com>
Tue, 19 Jul 2022 14:31:32 +0000 (14:31 +0000)
committerPaolo Bonzini <pbonzini@redhat.com>
Mon, 1 Aug 2022 12:01:22 +0000 (08:01 -0400)
commitad5b072716e9ea7164b578a06c615966e9203c45
treeafb41756421e398817938394783212f31d95c8a0
parent31f6e3832a0f1c366e54033335aed2375f6e447a
selftests: KVM: Check stat name before other fields

In order to provide more useful test assertions that describe the broken
stats descriptor, perform sanity check on the stat name before any other
descriptor field. While at it, avoid dereferencing the name field if the
sanity check fails as it is more likely to contain garbage.

Signed-off-by: Oliver Upton <oupton@google.com>
Reviewed-by: Andrew Jones <andrew.jones@linux.dev>
Message-Id: <20220719143134.3246798-2-oliver.upton@linux.dev>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
tools/testing/selftests/kvm/kvm_binary_stats_test.c