From: Thomas Huth <thuth@redhat.com>
To: Markus Armbruster <armbru@redhat.com>, qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, afaerber@suse.de, stefanha@redhat.com,
ehabkost@redhat.com
Subject: Re: [Qemu-devel] [PATCH v5 02/10] hw: do not pass NULL to memory_region_init from instance_init
Date: Thu, 1 Oct 2015 11:49:03 +0200 [thread overview]
Message-ID: <560D018F.8050801@redhat.com> (raw)
In-Reply-To: <1443689999-12182-3-git-send-email-armbru@redhat.com>
On 01/10/15 10:59, Markus Armbruster wrote:
> From: Paolo Bonzini <pbonzini@redhat.com>
>
> 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 <armbru@redhat.com>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> Message-Id: <1443530263-32340-3-git-send-email-pbonzini@redhat.com>
> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
> Tested-by: Markus Armbruster <armbru@redhat.com>
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
> hw/arm/pxa2xx.c | 2 +-
> hw/display/cg3.c | 4 ++--
> hw/display/tcx.c | 2 +-
> hw/misc/arm_integrator_debug.c | 2 +-
> hw/misc/macio/cuda.c | 2 +-
> hw/misc/macio/macio.c | 6 +++---
> hw/pcmcia/pxa2xx.c | 6 +++---
> 7 files changed, 12 insertions(+), 12 deletions(-)
>
> diff --git a/hw/arm/pxa2xx.c b/hw/arm/pxa2xx.c
> index 164260a..79d22d9 100644
> --- a/hw/arm/pxa2xx.c
> +++ b/hw/arm/pxa2xx.c
> @@ -1958,7 +1958,7 @@ static void pxa2xx_fir_instance_init(Object *obj)
> PXA2xxFIrState *s = PXA2XX_FIR(obj);
> SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
>
> - memory_region_init_io(&s->iomem, NULL, &pxa2xx_fir_ops, s,
> + memory_region_init_io(&s->iomem, obj, &pxa2xx_fir_ops, s,
> "pxa2xx-fir", 0x1000);
> sysbus_init_mmio(sbd, &s->iomem);
> sysbus_init_irq(sbd, &s->irq);
> diff --git a/hw/display/cg3.c b/hw/display/cg3.c
> index d2a0d97..e309fbe 100644
> --- a/hw/display/cg3.c
> +++ b/hw/display/cg3.c
> @@ -280,12 +280,12 @@ static void cg3_initfn(Object *obj)
> SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
> CG3State *s = CG3(obj);
>
> - memory_region_init_ram(&s->rom, NULL, "cg3.prom", FCODE_MAX_ROM_SIZE,
> + memory_region_init_ram(&s->rom, obj, "cg3.prom", FCODE_MAX_ROM_SIZE,
> &error_fatal);
> memory_region_set_readonly(&s->rom, true);
> sysbus_init_mmio(sbd, &s->rom);
>
> - memory_region_init_io(&s->reg, NULL, &cg3_reg_ops, s, "cg3.reg",
> + memory_region_init_io(&s->reg, obj, &cg3_reg_ops, s, "cg3.reg",
> CG3_REG_SIZE);
> sysbus_init_mmio(sbd, &s->reg);
> }
> diff --git a/hw/display/tcx.c b/hw/display/tcx.c
> index 4635800..bf119bc 100644
> --- a/hw/display/tcx.c
> +++ b/hw/display/tcx.c
> @@ -944,7 +944,7 @@ static void tcx_initfn(Object *obj)
> SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
> TCXState *s = TCX(obj);
>
> - memory_region_init_ram(&s->rom, NULL, "tcx.prom", FCODE_MAX_ROM_SIZE,
> + memory_region_init_ram(&s->rom, OBJECT(s), "tcx.prom", FCODE_MAX_ROM_SIZE,
> &error_fatal);
> memory_region_set_readonly(&s->rom, true);
> sysbus_init_mmio(sbd, &s->rom);
I'd still use "obj" instead of "OBJECT(s)", even if the rest of the
function is doing it differently ... but I guess we can also clean that
up later ...
So anyway, patch looks fine to me:
Reviewed-by: Thomas Huth <thuth@redhat.com>
next prev parent reply other threads:[~2015-10-01 9:49 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-01 8:59 [Qemu-devel] [PATCH v5 00/10] Fix device introspection regressions Markus Armbruster
2015-10-01 8:59 ` [Qemu-devel] [PATCH v5 01/10] memory: allow destroying a non-empty MemoryRegion Markus Armbruster
2015-10-01 8:59 ` [Qemu-devel] [PATCH v5 02/10] hw: do not pass NULL to memory_region_init from instance_init Markus Armbruster
2015-10-01 9:49 ` Thomas Huth [this message]
2015-10-01 8:59 ` [Qemu-devel] [PATCH v5 03/10] macio: move DBDMA_init from instance_init to realize Markus Armbruster
2015-10-01 8:59 ` [Qemu-devel] [PATCH v5 04/10] tests: Fix how qom-test is run Markus Armbruster
2015-10-01 8:59 ` [Qemu-devel] [PATCH v5 05/10] libqtest: Clean up unused QTestState member sigact_old Markus Armbruster
2015-10-01 10:02 ` Thomas Huth
2015-10-01 8:59 ` [Qemu-devel] [PATCH v5 06/10] libqtest: New hmp() & friends Markus Armbruster
2015-10-01 8:59 ` [Qemu-devel] [PATCH v5 07/10] device-introspect-test: New, covering device introspection Markus Armbruster
2015-10-01 8:59 ` [Qemu-devel] [PATCH v5 08/10] qmp: Fix device-list-properties not to crash for abstract device Markus Armbruster
2015-10-01 8:59 ` [Qemu-devel] [PATCH v5 09/10] qdev: Protect device-list-properties against broken devices Markus Armbruster
2015-10-01 8:59 ` [Qemu-devel] [PATCH v5 10/10] Revert "qdev: Use qdev_get_device_class() for -device <type>, help" Markus Armbruster
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=560D018F.8050801@redhat.com \
--to=thuth@redhat.com \
--cc=afaerber@suse.de \
--cc=armbru@redhat.com \
--cc=ehabkost@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).