summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/kvm/lib/x86_64/processor.c
diff options
context:
space:
mode:
authorIvan Orlov <ivan.orlov0322@gmail.com>2023-03-22 17:45:28 +0300
committerSean Christopherson <seanjc@google.com>2023-03-25 00:21:16 +0300
commit735b0e0f2d001b7ed9486db84453fb860e764a4d (patch)
tree99ec9cd1dfcf09df13fbdbed01230cde73347e9f /tools/testing/selftests/kvm/lib/x86_64/processor.c
parent8264e85560e5fae942ca42aae1df7daeb5aaa30e (diff)
downloadlinux-735b0e0f2d001b7ed9486db84453fb860e764a4d.tar.xz
KVM: selftests: Add 'malloc' failure check in vcpu_save_state
There is a 'malloc' call in vcpu_save_state function, which can be unsuccessful. This patch will add the malloc failure checking to avoid possible null dereference and give more information about test fail reasons. Signed-off-by: Ivan Orlov <ivan.orlov0322@gmail.com> Link: https://lore.kernel.org/r/20230322144528.704077-1-ivan.orlov0322@gmail.com Signed-off-by: Sean Christopherson <seanjc@google.com>
Diffstat (limited to 'tools/testing/selftests/kvm/lib/x86_64/processor.c')
-rw-r--r--tools/testing/selftests/kvm/lib/x86_64/processor.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/tools/testing/selftests/kvm/lib/x86_64/processor.c b/tools/testing/selftests/kvm/lib/x86_64/processor.c
index c09cd151fbe0..a12b21a2ef37 100644
--- a/tools/testing/selftests/kvm/lib/x86_64/processor.c
+++ b/tools/testing/selftests/kvm/lib/x86_64/processor.c
@@ -970,6 +970,7 @@ struct kvm_x86_state *vcpu_save_state(struct kvm_vcpu *vcpu)
vcpu_run_complete_io(vcpu);
state = malloc(sizeof(*state) + msr_list->nmsrs * sizeof(state->msrs.entries[0]));
+ TEST_ASSERT(state, "-ENOMEM when allocating kvm state");
vcpu_events_get(vcpu, &state->events);
vcpu_mp_state_get(vcpu, &state->mp_state);