Message ID | 1456771254-17511-15-git-send-email-armbru@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Mon, Feb 29, 2016 at 7:40 PM, Markus Armbruster <armbru@redhat.com> wrote: > We reuse errp after passing it host_memory_backend_get_memory(). If > both host_memory_backend_get_memory() and the reuse set an error, the > reuse will fail the assertion in error_setv(). Fortunately, > host_memory_backend_get_memory() can't fail. > > Pass it &error_abort to make our assumption explicit, and to get the > assertion failure in the right place should it become invalid. > > Signed-off-by: Markus Armbruster <armbru@redhat.com> > --- Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> > hw/misc/ivshmem.c | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) > > diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c > index 2850e8a..eb53d9a 100644 > --- a/hw/misc/ivshmem.c > +++ b/hw/misc/ivshmem.c > @@ -841,7 +841,7 @@ static void pci_ivshmem_realize(PCIDevice *dev, Error **errp) > g_warning("size argument ignored with hostmem"); > } > > - mr = host_memory_backend_get_memory(s->hostmem, errp); > + mr = host_memory_backend_get_memory(s->hostmem, &error_abort); > s->ivshmem_size = memory_region_size(mr); > } else if (s->sizearg == NULL) { > s->ivshmem_size = 4 << 20; /* 4 MB default */ > @@ -906,7 +906,8 @@ static void pci_ivshmem_realize(PCIDevice *dev, Error **errp) > > IVSHMEM_DPRINTF("using hostmem\n"); > > - mr = host_memory_backend_get_memory(MEMORY_BACKEND(s->hostmem), errp); > + mr = host_memory_backend_get_memory(MEMORY_BACKEND(s->hostmem), > + &error_abort); > vmstate_register_ram(mr, DEVICE(s)); > memory_region_add_subregion(&s->bar, 0, mr); > pci_register_bar(PCI_DEVICE(s), 2, attr, &s->bar); > @@ -1131,7 +1132,7 @@ static void ivshmem_check_memdev_is_busy(Object *obj, const char *name, > { > MemoryRegion *mr; > > - mr = host_memory_backend_get_memory(MEMORY_BACKEND(val), errp); > + mr = host_memory_backend_get_memory(MEMORY_BACKEND(val), &error_abort); > if (memory_region_is_mapped(mr)) { > char *path = object_get_canonical_path_component(val); > error_setg(errp, "can't use already busy memdev: %s", path); > -- > 2.4.3 > >
diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c index 2850e8a..eb53d9a 100644 --- a/hw/misc/ivshmem.c +++ b/hw/misc/ivshmem.c @@ -841,7 +841,7 @@ static void pci_ivshmem_realize(PCIDevice *dev, Error **errp) g_warning("size argument ignored with hostmem"); } - mr = host_memory_backend_get_memory(s->hostmem, errp); + mr = host_memory_backend_get_memory(s->hostmem, &error_abort); s->ivshmem_size = memory_region_size(mr); } else if (s->sizearg == NULL) { s->ivshmem_size = 4 << 20; /* 4 MB default */ @@ -906,7 +906,8 @@ static void pci_ivshmem_realize(PCIDevice *dev, Error **errp) IVSHMEM_DPRINTF("using hostmem\n"); - mr = host_memory_backend_get_memory(MEMORY_BACKEND(s->hostmem), errp); + mr = host_memory_backend_get_memory(MEMORY_BACKEND(s->hostmem), + &error_abort); vmstate_register_ram(mr, DEVICE(s)); memory_region_add_subregion(&s->bar, 0, mr); pci_register_bar(PCI_DEVICE(s), 2, attr, &s->bar); @@ -1131,7 +1132,7 @@ static void ivshmem_check_memdev_is_busy(Object *obj, const char *name, { MemoryRegion *mr; - mr = host_memory_backend_get_memory(MEMORY_BACKEND(val), errp); + mr = host_memory_backend_get_memory(MEMORY_BACKEND(val), &error_abort); if (memory_region_is_mapped(mr)) { char *path = object_get_canonical_path_component(val); error_setg(errp, "can't use already busy memdev: %s", path);
We reuse errp after passing it host_memory_backend_get_memory(). If both host_memory_backend_get_memory() and the reuse set an error, the reuse will fail the assertion in error_setv(). Fortunately, host_memory_backend_get_memory() can't fail. Pass it &error_abort to make our assumption explicit, and to get the assertion failure in the right place should it become invalid. Signed-off-by: Markus Armbruster <armbru@redhat.com> --- hw/misc/ivshmem.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)