Otherwise kvm will leak memory on multiple KVM_CREATE_IRQCHIP. CC: sta...@kernel.org Signed-off-by: Marcelo Tosatti <mtosa...@redhat.com>
Index: kvm/arch/x86/kvm/x86.c =================================================================== --- kvm.orig/arch/x86/kvm/x86.c +++ kvm/arch/x86/kvm/x86.c @@ -2285,6 +2285,9 @@ long kvm_arch_vm_ioctl(struct file *filp goto out; break; case KVM_CREATE_IRQCHIP: + r = -EEXIST; + if (kvm->arch.vpic) + goto out; r = -ENOMEM; kvm->arch.vpic = kvm_create_pic(kvm); if (kvm->arch.vpic) { @@ -2300,6 +2303,8 @@ long kvm_arch_vm_ioctl(struct file *filp if (r) { kfree(kvm->arch.vpic); kfree(kvm->arch.vioapic); + kvm->arch.vpic = NULL; + kvm->arch.vioapic = NULL; goto out; } break; -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html