Skip to content

Commit

Permalink
KVM: x86: fix memory leak in vmx_init
Browse files Browse the repository at this point in the history
Free vmx_msr_bitmap_longmode_x2apic and vmx_msr_bitmap_longmode if
kvm_init() fails.

Signed-off-by: Yang Zhang <yang.z.zhang@Intel.com>
Signed-off-by: Gleb Natapov <gleb@redhat.com>
  • Loading branch information
Yang Zhang authored and Gleb Natapov committed Apr 8, 2013
1 parent 05e07f9 commit 458f212
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion arch/x86/kvm/vmx.c
Original file line number Diff line number Diff line change
Expand Up @@ -7741,7 +7741,7 @@ static int __init vmx_init(void)
r = kvm_init(&vmx_x86_ops, sizeof(struct vcpu_vmx),
__alignof__(struct vcpu_vmx), THIS_MODULE);
if (r)
goto out3;
goto out5;

#ifdef CONFIG_KEXEC
rcu_assign_pointer(crash_vmclear_loaded_vmcss,
Expand Down Expand Up @@ -7789,6 +7789,8 @@ static int __init vmx_init(void)

return 0;

out5:
free_page((unsigned long)vmx_msr_bitmap_longmode_x2apic);
out4:
free_page((unsigned long)vmx_msr_bitmap_longmode);
out3:
Expand Down

0 comments on commit 458f212

Please sign in to comment.