From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: qemu-riscv@nongnu.org,
Sagar Karandikar <sagark@eecs.berkeley.edu>,
Bastian Koppelmann <kbastian@mail.uni-paderborn.de>,
Alistair Francis <alistair.francis@wdc.com>,
Palmer Dabbelt <palmer@dabbelt.com>,
Bin Meng <bmeng.cn@gmail.com>
Subject: [PULL 19/28] riscv/sifive_u: Fix sifive_u_soc_realize() error API violations
Date: Thu, 2 Jul 2020 13:09:22 +0200 [thread overview]
Message-ID: <20200702110931.2953148-20-armbru@redhat.com> (raw)
In-Reply-To: <20200702110931.2953148-1-armbru@redhat.com>
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>
Message-Id: <20200630090351.1247703-18-armbru@redhat.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
next prev parent reply other threads:[~2020-07-02 11:17 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-02 11:09 [PULL 00/28] Error reporting patches patches for 2020-07-02 Markus Armbruster
2020-07-02 11:09 ` [PULL 01/28] chardev/tcp: Fix error message double free error Markus Armbruster
2020-07-02 11:09 ` [PULL 02/28] hw/virtio/virtio-iommu-pci.c: Fix typo in error message Markus Armbruster
2020-07-02 11:09 ` [PULL 03/28] net/virtio: Fix failover_replug_primary() return value regression Markus Armbruster
2020-07-02 11:09 ` [PULL 04/28] pci: Delete useless error_propagate() Markus Armbruster
2020-07-02 11:09 ` [PULL 05/28] Clean up some calls to ignore Error objects the right way Markus Armbruster
2020-07-02 11:09 ` [PULL 06/28] tests: Use &error_abort where appropriate Markus Armbruster
2020-07-02 11:09 ` [PULL 07/28] tests: Use error_free_or_abort() " Markus Armbruster
2020-07-02 11:09 ` [PULL 08/28] usb/dev-mtp: Fix Error double free after inotify failure Markus Armbruster
2020-07-02 11:09 ` [PULL 09/28] spapr: Plug minor memory leak in spapr_machine_init() Markus Armbruster
2020-07-02 11:09 ` [PULL 10/28] qga: Plug unlikely memory leak in guest-set-memory-blocks Markus Armbruster
2020-07-02 11:09 ` [PULL 11/28] sd/milkymist-memcard: Plug minor memory leak in realize Markus Armbruster
2020-07-02 11:09 ` [PULL 12/28] test-util-filemonitor: Plug unlikely memory leak Markus Armbruster
2020-07-02 11:09 ` [PULL 13/28] vnc: Plug minor memory leak in vnc_display_open() Markus Armbruster
2020-07-02 11:09 ` [PULL 14/28] aspeed: Clean up roundabout error propagation Markus Armbruster
2020-07-02 11:09 ` [PULL 15/28] qdev: Drop qbus_set_bus_hotplug_handler() parameter @errp Markus Armbruster
2020-07-02 11:09 ` [PULL 16/28] qdev: Drop qbus_set_hotplug_handler() " Markus Armbruster
2020-07-02 11:09 ` [PULL 17/28] hw: Fix error API violation around object_property_set_link() Markus Armbruster
2020-07-02 11:09 ` [PULL 18/28] hw/arm: Drop useless object_property_set_link() error handling Markus Armbruster
2020-07-02 11:09 ` Markus Armbruster [this message]
2020-07-02 11:09 ` [PULL 20/28] riscv_hart: Fix riscv_harts_realize() error API violations Markus Armbruster
2020-07-02 11:09 ` [PULL 21/28] mips/cps: Fix mips_cps_realize() " Markus Armbruster
2020-07-02 11:09 ` [PULL 22/28] x86: Fix x86_cpu_new() error handling Markus Armbruster
2020-07-02 11:09 ` [PULL 23/28] amd_iommu: Fix amdvi_realize() error API violation Markus Armbruster
2020-07-02 11:09 ` [PULL 24/28] arm/stm32f205 arm/stm32f405: Fix realize " Markus Armbruster
2020-07-02 11:09 ` [PULL 25/28] aspeed: " Markus Armbruster
2020-07-02 11:09 ` [PULL 26/28] hw/arm/armsse: Fix armsse_realize() " Markus Armbruster
2020-07-02 11:09 ` [PULL 27/28] arm/{bcm2835, fsl-imx25, fsl-imx6}: Fix realize error API violations Markus Armbruster
2020-07-02 11:09 ` [PULL 28/28] migration/rdma: Plug memory leaks in qemu_rdma_registration_stop() Markus Armbruster
2020-07-02 16:00 ` [PULL 00/28] Error reporting patches patches for 2020-07-02 Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200702110931.2953148-20-armbru@redhat.com \
--to=armbru@redhat.com \
--cc=alistair.francis@wdc.com \
--cc=bmeng.cn@gmail.com \
--cc=kbastian@mail.uni-paderborn.de \
--cc=palmer@dabbelt.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-riscv@nongnu.org \
--cc=sagark@eecs.berkeley.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).