[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 19/26] mips/cps: Fix mips_cps_realize() error API violations
From: |
Markus Armbruster |
Subject: |
[PATCH v3 19/26] mips/cps: Fix mips_cps_realize() error API violations |
Date: |
Tue, 30 Jun 2020 11:03:44 +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.
mips_cps_realize() is wrong that way: it passes &err to multiple
object_property_set_FOO() without checking for failure, and then to
sysbus_realize(). Harmless, because the object_property_set_FOO()
can't actually fail here.
Fix by passing &error_abort instead.
Cc: Aleksandar Markovic <aleksandar.qemu.devel@gmail.com>
Cc: Aurelien Jarno <aurelien@aurel32.net>
Cc: Aleksandar Rikalo <aleksandar.rikalo@syrmia.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
hw/mips/cps.c | 29 +++++++++++++++++++----------
1 file changed, 19 insertions(+), 10 deletions(-)
diff --git a/hw/mips/cps.c b/hw/mips/cps.c
index 5382bc86f7..0d7f3cf673 100644
--- a/hw/mips/cps.c
+++ b/hw/mips/cps.c
@@ -100,10 +100,12 @@ static void mips_cps_realize(DeviceState *dev, Error
**errp)
/* Inter-Thread Communication Unit */
if (itu_present) {
object_initialize_child(OBJECT(dev), "itu", &s->itu, TYPE_MIPS_ITU);
- object_property_set_int(OBJECT(&s->itu), 16, "num-fifo", &err);
- object_property_set_int(OBJECT(&s->itu), 16, "num-semaphores", &err);
+ object_property_set_int(OBJECT(&s->itu), 16, "num-fifo",
+ &error_abort);
+ object_property_set_int(OBJECT(&s->itu), 16, "num-semaphores",
+ &error_abort);
object_property_set_bool(OBJECT(&s->itu), saar_present, "saar-present",
- &err);
+ &error_abort);
if (saar_present) {
s->itu.saar = &env->CP0_SAAR;
}
@@ -119,8 +121,10 @@ static void mips_cps_realize(DeviceState *dev, Error
**errp)
/* Cluster Power Controller */
object_initialize_child(OBJECT(dev), "cpc", &s->cpc, TYPE_MIPS_CPC);
- object_property_set_int(OBJECT(&s->cpc), s->num_vp, "num-vp", &err);
- object_property_set_int(OBJECT(&s->cpc), 1, "vp-start-running", &err);
+ object_property_set_int(OBJECT(&s->cpc), s->num_vp, "num-vp",
+ &error_abort);
+ object_property_set_int(OBJECT(&s->cpc), 1, "vp-start-running",
+ &error_abort);
sysbus_realize(SYS_BUS_DEVICE(&s->cpc), &err);
if (err != NULL) {
error_propagate(errp, err);
@@ -132,8 +136,10 @@ static void mips_cps_realize(DeviceState *dev, Error
**errp)
/* Global Interrupt Controller */
object_initialize_child(OBJECT(dev), "gic", &s->gic, TYPE_MIPS_GIC);
- object_property_set_int(OBJECT(&s->gic), s->num_vp, "num-vp", &err);
- object_property_set_int(OBJECT(&s->gic), 128, "num-irq", &err);
+ object_property_set_int(OBJECT(&s->gic), s->num_vp, "num-vp",
+ &error_abort);
+ object_property_set_int(OBJECT(&s->gic), 128, "num-irq",
+ &error_abort);
sysbus_realize(SYS_BUS_DEVICE(&s->gic), &err);
if (err != NULL) {
error_propagate(errp, err);
@@ -147,9 +153,12 @@ static void mips_cps_realize(DeviceState *dev, Error
**errp)
gcr_base = env->CP0_CMGCRBase << 4;
object_initialize_child(OBJECT(dev), "gcr", &s->gcr, TYPE_MIPS_GCR);
- object_property_set_int(OBJECT(&s->gcr), s->num_vp, "num-vp", &err);
- object_property_set_int(OBJECT(&s->gcr), 0x800, "gcr-rev", &err);
- object_property_set_int(OBJECT(&s->gcr), gcr_base, "gcr-base", &err);
+ object_property_set_int(OBJECT(&s->gcr), s->num_vp, "num-vp",
+ &error_abort);
+ object_property_set_int(OBJECT(&s->gcr), 0x800, "gcr-rev",
+ &error_abort);
+ object_property_set_int(OBJECT(&s->gcr), gcr_base, "gcr-base",
+ &error_abort);
object_property_set_link(OBJECT(&s->gcr), OBJECT(&s->gic.mr), "gic",
&error_abort);
object_property_set_link(OBJECT(&s->gcr), OBJECT(&s->cpc.mr), "cpc",
--
2.26.2
- Re: [PATCH v3 22/26] arm/stm32f205 arm/stm32f405: Fix realize error API violation, (continued)
- [PATCH v3 20/26] x86: Fix x86_cpu_new() error handling, Markus Armbruster, 2020/06/30
- [PATCH v3 06/26] usb/dev-mtp: Fix Error double free after inotify failure, Markus Armbruster, 2020/06/30
- [PATCH v3 26/26] migration/rdma: Plug memory leaks in qemu_rdma_registration_stop(), Markus Armbruster, 2020/06/30
- [PATCH v3 16/26] hw/arm: Drop useless object_property_set_link() error handling, Markus Armbruster, 2020/06/30
- [PATCH v3 24/26] hw/arm/armsse: Fix armsse_realize() error API violation, Markus Armbruster, 2020/06/30
- [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 <=
- [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, 2020/06/30
- [PATCH v3 23/26] aspeed: Fix realize error API violation, Markus Armbruster, 2020/06/30