[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 18/26] riscv_hart: Fix riscv_harts_realize() error API violati
From: |
Markus Armbruster |
Subject: |
[PATCH v3 18/26] riscv_hart: Fix riscv_harts_realize() error API violations |
Date: |
Tue, 30 Jun 2020 11:03:43 +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.
riscv_harts_realize() is wrong that way: it passes @errp to
riscv_hart_realize() in a loop. I can't tell offhand whether this can
fail.
Fix by checking for failure in each iteration.
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Alistair Francis <Alistair.Francis@wdc.com>
Cc: Sagar Karandikar <sagark@eecs.berkeley.edu>
Cc: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
Cc: Bin Meng <bmeng.cn@gmail.com>
Cc: qemu-riscv@nongnu.org
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
---
hw/riscv/riscv_hart.c | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
diff --git a/hw/riscv/riscv_hart.c b/hw/riscv/riscv_hart.c
index e26c382259..f59fe52f0f 100644
--- a/hw/riscv/riscv_hart.c
+++ b/hw/riscv/riscv_hart.c
@@ -40,19 +40,13 @@ static void riscv_harts_cpu_reset(void *opaque)
cpu_reset(CPU(cpu));
}
-static void riscv_hart_realize(RISCVHartArrayState *s, int idx,
+static bool riscv_hart_realize(RISCVHartArrayState *s, int idx,
char *cpu_type, Error **errp)
{
- Error *err = NULL;
-
object_initialize_child(OBJECT(s), "harts[*]", &s->harts[idx], cpu_type);
s->harts[idx].env.mhartid = s->hartid_base + idx;
qemu_register_reset(riscv_harts_cpu_reset, &s->harts[idx]);
- qdev_realize(DEVICE(&s->harts[idx]), NULL, &err);
- if (err) {
- error_propagate(errp, err);
- return;
- }
+ return qdev_realize(DEVICE(&s->harts[idx]), NULL, errp);
}
static void riscv_harts_realize(DeviceState *dev, Error **errp)
@@ -63,7 +57,9 @@ static void riscv_harts_realize(DeviceState *dev, Error
**errp)
s->harts = g_new0(RISCVCPU, s->num_harts);
for (n = 0; n < s->num_harts; n++) {
- riscv_hart_realize(s, n, s->cpu_type, errp);
+ if (!riscv_hart_realize(s, n, s->cpu_type, errp)) {
+ return;
+ }
}
}
--
2.26.2
- [PATCH v3 20/26] x86: Fix x86_cpu_new() error handling, (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, 2020/06/30
- [PATCH v3 18/26] riscv_hart: Fix riscv_harts_realize() error API violations,
Markus Armbruster <=
- [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