[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 21/26] amd_iommu: Fix amdvi_realize() error API violation
From: |
Markus Armbruster |
Subject: |
[PATCH v3 21/26] amd_iommu: Fix amdvi_realize() error API violation |
Date: |
Tue, 30 Jun 2020 11:03:46 +0200 |
The Error ** argument must be NULL, &error_abort, &error_fatal, or a
pointer to a variable containing NULL. Passing an argument of the
latter kind twice without clearing it in between is wrong: if the
first call sets an error, it no longer points to NULL for the second
call.
amdvi_realize() is wrong that way: it passes @errp to qdev_realize(),
object_property_get_int(), and msi_init() without checking it. I
can't tell offhand whether qdev_realize() can fail here. Fix by
checking it for failure. object_property_get_int() can't. Fix by
passing &error_abort instead.
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
hw/i386/amd_iommu.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c
index b26d30da57..087f601666 100644
--- a/hw/i386/amd_iommu.c
+++ b/hw/i386/amd_iommu.c
@@ -1549,7 +1549,9 @@ static void amdvi_realize(DeviceState *dev, Error **errp)
/* This device should take care of IOMMU PCI properties */
x86_iommu->type = TYPE_AMD;
- qdev_realize(DEVICE(&s->pci), &bus->qbus, errp);
+ if (!qdev_realize(DEVICE(&s->pci), &bus->qbus, errp)) {
+ return;
+ }
ret = pci_add_capability(&s->pci.dev, AMDVI_CAPAB_ID_SEC, 0,
AMDVI_CAPAB_SIZE, errp);
if (ret < 0) {
@@ -1578,7 +1580,7 @@ static void amdvi_realize(DeviceState *dev, Error **errp)
sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->mmio);
sysbus_mmio_map(SYS_BUS_DEVICE(s), 0, AMDVI_BASE_ADDR);
pci_setup_iommu(bus, amdvi_host_dma_iommu, s);
- s->devid = object_property_get_int(OBJECT(&s->pci), "addr", errp);
+ s->devid = object_property_get_int(OBJECT(&s->pci), "addr", &error_abort);
msi_init(&s->pci.dev, 0, 1, true, false, errp);
amdvi_init(s);
}
--
2.26.2
- [PATCH v3 17/26] riscv/sifive_u: Fix sifive_u_soc_realize() error API violations, (continued)
- [PATCH v3 17/26] riscv/sifive_u: Fix sifive_u_soc_realize() error API violations, Markus Armbruster, 2020/06/30
- [PATCH v3 19/26] mips/cps: Fix mips_cps_realize() error API violations, Markus Armbruster, 2020/06/30
- [PATCH v3 18/26] riscv_hart: Fix riscv_harts_realize() error API violations, Markus Armbruster, 2020/06/30
- [PATCH v3 25/26] arm/{bcm2835, fsl-imx25, fsl-imx6}: Fix realize error API violations, Markus Armbruster, 2020/06/30
- [PATCH v3 11/26] vnc: Plug minor memory leak in vnc_display_open(), Markus Armbruster, 2020/06/30
- [PATCH v3 02/26] pci: Delete useless error_propagate(), Markus Armbruster, 2020/06/30
- [PATCH v3 15/26] hw: Fix error API violation around object_property_set_link(), Markus Armbruster, 2020/06/30
- [PATCH v3 21/26] amd_iommu: Fix amdvi_realize() error API violation,
Markus Armbruster <=
- [PATCH v3 23/26] aspeed: Fix realize error API violation, Markus Armbruster, 2020/06/30
- [PATCH v3 01/26] net/virtio: Fix failover_replug_primary() return value regression, Markus Armbruster, 2020/06/30