[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 18/22] riscv/sifive_u: Fix sifive_u_soc_realize() error API v
From: |
Alistair Francis |
Subject: |
Re: [PATCH 18/22] riscv/sifive_u: Fix sifive_u_soc_realize() error API violations |
Date: |
Mon, 22 Jun 2020 14:23:36 -0700 |
On Mon, Jun 22, 2020 at 3:55 AM Markus Armbruster <armbru@redhat.com> wrote:
>
> 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() three times before checking it. Harmless, because
> the first two 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>
Alistair
> ---
> hw/riscv/sifive_u.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c
> index ea197ab64f..3857b92d9a 100644
> --- a/hw/riscv/sifive_u.c
> +++ b/hw/riscv/sifive_u.c
> @@ -587,11 +587,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->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);
>
> for (i = 0; i < SIFIVE_U_PLIC_NUM_SOURCES; i++) {
> --
> 2.26.2
>
>
- [PATCH 08/22] qga: Plug unlikely memory leak in guest-set-memory-blocks, (continued)
- [PATCH 08/22] qga: Plug unlikely memory leak in guest-set-memory-blocks, Markus Armbruster, 2020/06/22
- [PATCH 15/22] qdev: Drop qbus_set_hotplug_handler() parameter @errp, Markus Armbruster, 2020/06/22
- [PATCH 19/22] riscv_hart: Fix riscv_harts_realize() error API violations, Markus Armbruster, 2020/06/22
- [PATCH 07/22] spapr: Plug minor memory leak in spapr_machine_init(), Markus Armbruster, 2020/06/22
- [PATCH 11/22] vnc: Plug minor memory leak in vnc_display_open(), Markus Armbruster, 2020/06/22
- [PATCH 22/22] amd_iommu: Fix amdvi_realize() error API violation, Markus Armbruster, 2020/06/22
- [PATCH 18/22] riscv/sifive_u: Fix sifive_u_soc_realize() error API violations, Markus Armbruster, 2020/06/22
- Re: [PATCH 18/22] riscv/sifive_u: Fix sifive_u_soc_realize() error API violations,
Alistair Francis <=
- [PATCH 17/22] hw/arm: Drop useless object_property_set_link() error handling, Markus Armbruster, 2020/06/22
- [PATCH 01/22] net/virtio: Fix failover_replug_primary() return value regression, Markus Armbruster, 2020/06/22
- [PATCH 13/22] aspeed: Clean up roundabout error propagation, Markus Armbruster, 2020/06/22
- [PATCH 06/22] usb/dev-mtp: Fix Error double free after inotify failure, Markus Armbruster, 2020/06/22
- [PATCH 02/22] pci: Delete useless error_propagate(), Markus Armbruster, 2020/06/22