From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49176) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zhard-0008DR-Hr for qemu-devel@nongnu.org; Thu, 01 Oct 2015 06:13:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZharY-0000vV-IJ for qemu-devel@nongnu.org; Thu, 01 Oct 2015 06:13:25 -0400 Sender: Paolo Bonzini References: <1443530263-32340-1-git-send-email-pbonzini@redhat.com> <1443530263-32340-3-git-send-email-pbonzini@redhat.com> <87eghg8etz.fsf@blackfin.pond.sub.org> <560BDDAF.4070408@redhat.com> <87io6rdoli.fsf@blackfin.pond.sub.org> From: Paolo Bonzini Message-ID: <560D0731.40406@redhat.com> Date: Thu, 1 Oct 2015 12:13:05 +0200 MIME-Version: 1.0 In-Reply-To: <87io6rdoli.fsf@blackfin.pond.sub.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH 2/3] hw: do not pass NULL to memory_region_init from instance_init List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: peter.maydell@linaro.org, mark.cave-ayland@ilande.co.uk, qemu-devel@nongnu.org, agraf@suse.de, blauwirbel@gmail.com, qemu-ppc@nongnu.org On 01/10/2015 09:39, Markus Armbruster wrote: > Paolo Bonzini writes: > >> On 30/09/2015 10:57, Markus Armbruster wrote: >>> Paolo Bonzini writes: >>> >>>>> This causes the region to outlive the object, because it attaches the >>>>> region to /machine. This is not nice for the "realize" method, but >>>>> much worse for "instance_init" because it can cause dangling pointers >>>>> after a simple object_new/object_unref pair. >>>>> >>>>> Reported-by: Markus Armbruster >>>>> Signed-off-by: Paolo Bonzini >>> One more: pxa2xx_pcmcia_initfn(). >>> >>> The ones you fix are >>> Tested-by: Markus Armbruster >> >> Can you fix it up and take it through your series? > > Like this? > > From 14ce586f3e8a7ced07ec37ed60ad71ca55f41a08 Mon Sep 17 00:00:00 2001 > From: Markus Armbruster > Date: Thu, 1 Oct 2015 09:36:39 +0200 > Subject: [PATCH] fixup! hw: do not pass NULL to memory_region_init from > instance_init > > --- > hw/pcmcia/pxa2xx.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/hw/pcmcia/pxa2xx.c b/hw/pcmcia/pxa2xx.c > index e0de8a6..23649bc 100644 > --- a/hw/pcmcia/pxa2xx.c > +++ b/hw/pcmcia/pxa2xx.c > @@ -163,7 +163,7 @@ static void pxa2xx_pcmcia_initfn(Object *obj) > sysbus_init_mmio(sbd, &s->container_mem); > > /* Socket I/O Memory Space */ > - memory_region_init_io(&s->iomem, NULL, &pxa2xx_pcmcia_io_ops, s, > + memory_region_init_io(&s->iomem, obj, &pxa2xx_pcmcia_io_ops, s, > "pxa2xx-pcmcia-io", 0x04000000); > memory_region_add_subregion(&s->container_mem, 0x00000000, > &s->iomem); > @@ -171,13 +171,13 @@ static void pxa2xx_pcmcia_initfn(Object *obj) > /* Then next 64 MB is reserved */ > > /* Socket Attribute Memory Space */ > - memory_region_init_io(&s->attr_iomem, NULL, &pxa2xx_pcmcia_attr_ops, s, > + memory_region_init_io(&s->attr_iomem, obj, &pxa2xx_pcmcia_attr_ops, s, > "pxa2xx-pcmcia-attribute", 0x04000000); > memory_region_add_subregion(&s->container_mem, 0x08000000, > &s->attr_iomem); > > /* Socket Common Memory Space */ > - memory_region_init_io(&s->common_iomem, NULL, &pxa2xx_pcmcia_common_ops, s, > + memory_region_init_io(&s->common_iomem, obj, &pxa2xx_pcmcia_common_ops, s, > "pxa2xx-pcmcia-common", 0x04000000); > memory_region_add_subregion(&s->container_mem, 0x0c000000, > &s->common_iomem); > Yes, thanks! Paolo