From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Michael S. Tsirkin" Subject: Re: [patch 1/3] KVM: x86: disallow multiple KVM_CREATE_IRQCHIP Date: Tue, 27 Oct 2009 19:49:25 +0200 Message-ID: <20091027174925.GB14421@redhat.com> References: <20091027151042.118902183@redhat.com> <20091027151125.287873732@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: avi@redhat.com, kvm , stable@kernel.org To: Marcelo Tosatti Return-path: Received: from mx1.redhat.com ([209.132.183.28]:63234 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756174AbZJ0RwD (ORCPT ); Tue, 27 Oct 2009 13:52:03 -0400 Content-Disposition: inline In-Reply-To: <20091027151125.287873732@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On Tue, Oct 27, 2009 at 01:10:43PM -0200, Marcelo Tosatti wrote: > Otherwise kvm will leak memory on multiple KVM_CREATE_IRQCHIP. > > CC: stable@kernel.org > Signed-off-by: Marcelo Tosatti > > 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; Is there a lock that protects this structure? Can memory leak still occur if multiple threads call KVM_CREATE_IRQCHIP in parallel? > > -- > To unsubscribe from this list: send the line "unsubscribe kvm" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html