Skip to content

Commit bfbb307

Browse files
Dan Carpenterbonzini
authored andcommitted
KVM: VMX: Set failure code in prepare_vmcs02()
The error paths in the prepare_vmcs02() function are supposed to set *entry_failure_code but this path does not. It leads to using an uninitialized variable in the caller. Fixes: 71f7347 ("KVM: nVMX: Load GUEST_IA32_PERF_GLOBAL_CTRL MSR on VM-Entry") Signed-off-by: Dan Carpenter <[email protected]> Message-Id: <20211130125337.GB24578@kili> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent ef8b4b7 commit bfbb307

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

arch/x86/kvm/vmx/nested.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2591,8 +2591,10 @@ static int prepare_vmcs02(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12,
25912591

25922592
if ((vmcs12->vm_entry_controls & VM_ENTRY_LOAD_IA32_PERF_GLOBAL_CTRL) &&
25932593
WARN_ON_ONCE(kvm_set_msr(vcpu, MSR_CORE_PERF_GLOBAL_CTRL,
2594-
vmcs12->guest_ia32_perf_global_ctrl)))
2594+
vmcs12->guest_ia32_perf_global_ctrl))) {
2595+
*entry_failure_code = ENTRY_FAIL_DEFAULT;
25952596
return -EINVAL;
2597+
}
25962598

25972599
kvm_rsp_write(vcpu, vmcs12->guest_rsp);
25982600
kvm_rip_write(vcpu, vmcs12->guest_rip);

0 commit comments

Comments
 (0)