Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751944AbcDTRxl (ORCPT ); Wed, 20 Apr 2016 13:53:41 -0400 Received: from e06smtp12.uk.ibm.com ([195.75.94.108]:41786 "EHLO e06smtp12.uk.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751185AbcDTRxj convert rfc822-to-8bit (ORCPT ); Wed, 20 Apr 2016 13:53:39 -0400 X-IBM-Helo: d06dlp03.portsmouth.uk.ibm.com X-IBM-MailFrom: gkurz@linux.vnet.ibm.com X-IBM-RcptTo: kvm@vger.kernel.org;linux-kernel@vger.kernel.org Date: Wed, 20 Apr 2016 19:53:29 +0200 From: Greg Kurz To: Radim =?UTF-8?B?S3LEjW3DocWZ?= Cc: James Hogan , Paolo Bonzini , mingo@redhat.com, linux-mips@linux-mips.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, qemu-ppc@nongnu.org, Cornelia Huck , Paul Mackerras , David Gibson Subject: Re: [PATCH v3] KVM: remove buggy vcpu id check on vcpu creation Message-ID: <20160420195329.23c8982c@bahia.huguette.org> In-Reply-To: <20160420172706.GA4044@potion> References: <146116689259.20666.15860134511726195550.stgit@bahia.huguette.org> <20160420170209.GA11071@potion> <20160420170924.GA7859@jhogan-linux.le.imgtec.org> <20160420172706.GA4044@potion> Organization: IBM X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.30; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16042017-0009-0000-0000-0000158B193F Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1112 Lines: 37 On Wed, 20 Apr 2016 19:27:06 +0200 Radim Krčmář wrote: > 2016-04-20 18:09+0100, James Hogan: > > On Wed, Apr 20, 2016 at 07:02:10PM +0200, Radim Krčmář wrote: > >> 2016-04-20 17:44+0200, Greg Kurz: > >> > diff --git a/arch/mips/kvm/mips.c b/arch/mips/kvm/mips.c > >> > index 70ef1a43c114..0278ea146db5 100644 > >> > --- a/arch/mips/kvm/mips.c > >> > +++ b/arch/mips/kvm/mips.c > >> > @@ -248,9 +248,14 @@ struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm, unsigned int id) > >> > int err, size, offset; > >> > void *gebase; > >> > int i; > >> > + struct kvm_vcpu *vcpu; > >> > > >> > - struct kvm_vcpu *vcpu = kzalloc(sizeof(struct kvm_vcpu), GFP_KERNEL); > >> > + if (id >= KVM_MAX_VCPUS) { > >> > + err = -EINVAL; > >> > + goto out; > >> > >> 'vcpu' looks undefined at this point, so kfree in 'out:' may bug. > > > > Thats out_free_cpu I think? > > My bad, it is. Thank you! > I kept the goto based construct because it was done this way for kzalloc(). but I agree that 'return ERR_PTR(-EINVAL)' may look more explicit. Worth a v4 ? Cheers. -- Greg