From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:34721) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UF1ev-0008Jr-Ji for qemu-devel@nongnu.org; Mon, 11 Mar 2013 08:16:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UF1es-0008DP-2U for qemu-devel@nongnu.org; Mon, 11 Mar 2013 08:16:53 -0400 Received: from mail-qc0-x22d.google.com ([2607:f8b0:400d:c01::22d]:35843) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UF1er-0008DC-TG for qemu-devel@nongnu.org; Mon, 11 Mar 2013 08:16:49 -0400 Received: by mail-qc0-f173.google.com with SMTP id b12so1457062qca.18 for ; Mon, 11 Mar 2013 05:16:49 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <513DCB2C.5030404@redhat.com> Date: Mon, 11 Mar 2013 13:16:44 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <1489845274.730285.1361778940139.JavaMail.root@redhat.com> <512B1C35.3040500@de.ibm.com> <512B4073.6050100@redhat.com> <512B46C3.4030805@de.ibm.com> <20130311130447.620e713d@gondolin> In-Reply-To: <20130311130447.620e713d@gondolin> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 1/3] virtio-ccw: remove qdev_unparent in unplug routing List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Cornelia Huck Cc: Christian Borntraeger , Jens Freimann , Alexander Graf , =?ISO-8859-1?Q?Andreas_F=E4rber?= , qemu-devel Il 11/03/2013 13:04, Cornelia Huck ha scritto: > On Fri, 8 Mar 2013 21:11:13 +0100 > Alexander Graf wrote: > >> >> On 25.02.2013, at 12:10, Christian Borntraeger wrote: >> >>> On 25/02/13 11:44, Paolo Bonzini wrote: >>>> Il 25/02/2013 09:09, Christian Borntraeger ha scritto: >>>>> Hmm, the old sequence was >>>>> >>>>> object_unparent(OBJECT(dev)); >>>>> qdev_free(dev) ---+ >>>>> | >>>>> V >>>>> ... >>>>> object_unparent(OBJECT(dev)); now the last reference is gone, object is freed >>>>> object_unref(OBJECT(dev)); now the reference of a deleted object becomes -1 >>>>> ... >>>>> >>>>> Isnt that a problem in itself that we modify a reference counter in an deleted object? >>>> >>>> The second object_unparent should do nothing. So before you had: >>>> >>>> object_unparent(OBJECT(dev)); leaves refcount=1 >>>> qdev_free(dev) ---+ >>>> | >>>> V >>>> object_unparent(OBJECT(dev)); do nothing >>>> object_unref(OBJECT(dev)); refcount=0, object freed >>>> >>>> After the object_unref was removed you had: >>>> >>>> object_unparent(OBJECT(dev)); refcount=0, object freed >>>> qdev_free(dev) ---+ >>>> | >>>> V >>>> object_unparent(OBJECT(dev)); dangling pointer! >>>> >>> >>> >>> Got it. Thanks >> >> So is the patch valid? > > To my understanding, yes. Yes, except that the "fixed a crash" part in the commit message is probably no longer accurate. No big deal. :) Paolo