From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47801) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHnxB-0005Qe-Qp for qemu-devel@nongnu.org; Tue, 28 Jun 2016 04:01:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bHnx7-0005as-Nz for qemu-devel@nongnu.org; Tue, 28 Jun 2016 04:01:04 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:31803) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHnx7-0005ab-FR for qemu-devel@nongnu.org; Tue, 28 Jun 2016 04:01:01 -0400 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id u5S7x1V3118957 for ; Tue, 28 Jun 2016 04:00:59 -0400 Received: from e23smtp07.au.ibm.com (e23smtp07.au.ibm.com [202.81.31.140]) by mx0a-001b2d01.pphosted.com with ESMTP id 23sp425rbk-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 28 Jun 2016 04:00:59 -0400 Received: from localhost by e23smtp07.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 28 Jun 2016 18:00:56 +1000 Date: Tue, 28 Jun 2016 13:30:47 +0530 From: Bharata B Rao Reply-To: bharata@linux.vnet.ibm.com References: <146704489509.8607.12236848738501803903.stgit@bahia.lan> <20160628025507.GS4242@voom.fritz.box> <20160628072416.2c1f2286@bahia.lan> <20160628062422.GF4242@voom.fritz.box> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160628062422.GF4242@voom.fritz.box> Message-Id: <20160628080047.GG27296@in.ibm.com> Subject: Re: [Qemu-devel] [PATCH] spapr: fix write-past-end-of-array error in cpu core device init code List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: David Gibson Cc: Greg Kurz , qemu-devel@nongnu.org, qemu-ppc@nongnu.org, Alexander Graf On Tue, Jun 28, 2016 at 04:24:22PM +1000, David Gibson wrote: > On Tue, Jun 28, 2016 at 07:24:16AM +0200, Greg Kurz wrote: > > On Tue, 28 Jun 2016 12:55:07 +1000 > > David Gibson wrote: > > > > > On Mon, Jun 27, 2016 at 06:28:15PM +0200, Greg Kurz wrote: > > > > This fixes a potential QEMU crash introduced by commit 3b542549661. > > > > > > > > Signed-off-by: Greg Kurz > > > > --- > > > > hw/ppc/spapr_cpu_core.c | 3 +-- > > > > 1 file changed, 1 insertion(+), 2 deletions(-) > > > > > > Ugh. The existing code is wrong in the case where the failure happens > > > after the loop. > > > > > > But this version is wrong in the case it happens during the loop - it > > > will fail to clean up the last object created. > > > > > > > Hmm... unless I'm missing something, if object_property_add_child() fails to > > add object i, we don't want to unparent it, and we should start rollback > > at index i-1. > > Good point, my mistake. I'll apply this fix. > > > > > Another weirdness is that I see no rollback for the object_child_foreach() > > loop: in case of failure, we will unparent realized objects... is it > > okay ? > > Um.. I have no idea. Bharata? Alex? This is similar to how device_add code recovers when there is failure during realize. So I think object_unparent() should be fine. Only other thing I need to verify is whether an additional object_unref() is needed after unparenting. Regards, Bharata.