[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 17/25] riscv/sifive_u: Fix sifive_u_soc_realize() error API vi
From: |
Markus Armbruster |
Subject: |
[PATCH v2 17/25] riscv/sifive_u: Fix sifive_u_soc_realize() error API violations |
Date: |
Wed, 24 Jun 2020 10:37:29 +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.
sifive_u_soc_realize() is wrong that way: it passes &err to
sysbus_realize() four times before checking it. Harmless, because the
first three can't actually fail (I think).
Fix by checking for failure right away.
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/sifive_u.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c
index 7d051e7c92..a1d2edfe13 100644
--- a/hw/riscv/sifive_u.c
+++ b/hw/riscv/sifive_u.c
@@ -677,11 +677,15 @@ static void sifive_u_soc_realize(DeviceState *dev, Error
**errp)
memmap[SIFIVE_U_CLINT].size, ms->smp.cpus,
SIFIVE_SIP_BASE, SIFIVE_TIMECMP_BASE, SIFIVE_TIME_BASE, false);
- sysbus_realize(SYS_BUS_DEVICE(&s->prci), &err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->prci), errp)) {
+ return;
+ }
sysbus_mmio_map(SYS_BUS_DEVICE(&s->prci), 0, memmap[SIFIVE_U_PRCI].base);
qdev_prop_set_uint32(DEVICE(&s->gpio), "ngpio", 16);
- sysbus_realize(SYS_BUS_DEVICE(&s->gpio), &err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->gpio), errp)) {
+ return;
+ }
sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpio), 0, memmap[SIFIVE_U_GPIO].base);
/* Pass all GPIOs to the SOC layer so they are available to the board */
@@ -695,7 +699,9 @@ static void sifive_u_soc_realize(DeviceState *dev, Error
**errp)
}
qdev_prop_set_uint32(DEVICE(&s->otp), "serial", s->serial);
- sysbus_realize(SYS_BUS_DEVICE(&s->otp), &err);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->otp), errp)) {
+ return;
+ }
sysbus_mmio_map(SYS_BUS_DEVICE(&s->otp), 0, memmap[SIFIVE_U_OTP].base);
if (nd->used) {
--
2.26.2
- Re: [PATCH v2 03/25] Clean up some calls to ignore Error objects the right way, (continued)
- [PATCH v2 04/25] tests: Use &error_abort where appropriate, Markus Armbruster, 2020/06/24
- [PATCH v2 13/25] qdev: Drop qbus_set_bus_hotplug_handler() parameter @errp, Markus Armbruster, 2020/06/24
- [PATCH v2 12/25] aspeed: Clean up roundabout error propagation, Markus Armbruster, 2020/06/24
- [PATCH v2 09/25] sd/milkymist-memcard: Plug minor memory leak in realize, Markus Armbruster, 2020/06/24
- [PATCH v2 08/25] qga: Plug unlikely memory leak in guest-set-memory-blocks, Markus Armbruster, 2020/06/24
- [PATCH v2 20/25] x86: Fix x86_cpu_new() error API violations, Markus Armbruster, 2020/06/24
- [PATCH v2 06/25] usb/dev-mtp: Fix Error double free after inotify failure, Markus Armbruster, 2020/06/24
- [PATCH v2 17/25] riscv/sifive_u: Fix sifive_u_soc_realize() error API violations,
Markus Armbruster <=
- [PATCH v2 19/25] mips/cps: Fix mips_cps_realize() error API violations, Markus Armbruster, 2020/06/24
- [PATCH v2 02/25] pci: Delete useless error_propagate(), Markus Armbruster, 2020/06/24
- [PATCH v2 01/25] net/virtio: Fix failover_replug_primary() return value regression, Markus Armbruster, 2020/06/24
- [PATCH v2 18/25] riscv_hart: Fix riscv_harts_realize() error API violations, Markus Armbruster, 2020/06/24
- [PATCH v2 11/25] vnc: Plug minor memory leak in vnc_display_open(), Markus Armbruster, 2020/06/24
- [PATCH v2 23/25] aspeed: Fix realize error API violation, Markus Armbruster, 2020/06/24
- [PATCH v2 25/25] arm/{bcm2835, fsl-imx25, fsl-imx6}: Fix realize error API violations, Markus Armbruster, 2020/06/24
- [PATCH v2 22/25] arm/stm32f205 arm/stm32f405: Fix realize error API violation, Markus Armbruster, 2020/06/24
- [PATCH v2 24/25] hw/arm/armsse: Fix armsse_realize() error API violation, Markus Armbruster, 2020/06/24