Re: [PATCH v5 3/7] kvm: Make init_rmode_identity_map() return 0 on success.
From: tangchen
Date: Thu Sep 11 2014 - 06:26:01 EST
On 09/11/2014 05:17 PM, Paolo Bonzini wrote:
......
@@ -7645,7 +7642,7 @@ static struct kvm_vcpu *vmx_create_vcpu(struct kvm *kvm, unsigned int id)
kvm->arch.ept_identity_map_addr =
VMX_EPT_IDENTITY_PAGETABLE_ADDR;
err = -ENOMEM;
- if (!init_rmode_identity_map(kvm))
+ if (init_rmode_identity_map(kvm))
Please add "< 0" here. I would also consider setting err to the return
value of init_rmode_identity_map, and initializing it to -ENOMEM only
after the "if".
I'd like to move err = -ENOMEM to the following place:
vmx_create_vcpu()
{
......
err = kvm_vcpu_init(&vmx->vcpu, kvm, id);
if (err)
goto free_vcpu;
err = -ENOMEM; ---------------------- move it here
vmx->guest_msrs = kmalloc(PAGE_SIZE, GFP_KERNEL);
....
vmx->loaded_vmcs->vmcs = alloc_vmcs();
....
}
So that it can be used to handle the next two memory allocation error.
Thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/