aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Kiszka <jan.kiszka@siemens.com>2011-04-12 19:27:55 -0400
committerAvi Kivity <avi@redhat.com>2011-05-11 07:57:08 -0400
commitbe6d05cfdf1f2ddbdc367a6433d8eac49d6bfe6f (patch)
tree4e20ff818c63f8b9a7c7b84d101f5c669eee454a
parent7ae441eac521b2006c9f03c4f2a23582c07fd76d (diff)
KVM: VMX: Ensure that vmx_create_vcpu always returns proper error
In case certain allocations fail, vmx_create_vcpu may return 0 as error instead of a negative value encoded via ERR_PTR. This causes a NULL pointer dereferencing later on in kvm_vm_ioctl_vcpu_create. Reported-by: Sasha Levin <levinsasha928@gmail.com> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
-rw-r--r--arch/x86/kvm/vmx.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index aabe3334d064..af5206983154 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -4251,8 +4251,8 @@ static struct kvm_vcpu *vmx_create_vcpu(struct kvm *kvm, unsigned int id)
4251 goto free_vcpu; 4251 goto free_vcpu;
4252 4252
4253 vmx->guest_msrs = kmalloc(PAGE_SIZE, GFP_KERNEL); 4253 vmx->guest_msrs = kmalloc(PAGE_SIZE, GFP_KERNEL);
4254 err = -ENOMEM;
4254 if (!vmx->guest_msrs) { 4255 if (!vmx->guest_msrs) {
4255 err = -ENOMEM;
4256 goto uninit_vcpu; 4256 goto uninit_vcpu;
4257 } 4257 }
4258 4258
@@ -4271,7 +4271,8 @@ static struct kvm_vcpu *vmx_create_vcpu(struct kvm *kvm, unsigned int id)
4271 if (err) 4271 if (err)
4272 goto free_vmcs; 4272 goto free_vmcs;
4273 if (vm_need_virtualize_apic_accesses(kvm)) 4273 if (vm_need_virtualize_apic_accesses(kvm))
4274 if (alloc_apic_access_page(kvm) != 0) 4274 err = alloc_apic_access_page(kvm);
4275 if (err)
4275 goto free_vmcs; 4276 goto free_vmcs;
4276 4277
4277 if (enable_ept) { 4278 if (enable_ept) {