[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 10/15] hw/acpi/erst: Do not ignore Error* in realize handler
From: |
Michael S. Tsirkin |
Subject: |
[PULL 10/15] hw/acpi/erst: Do not ignore Error* in realize handler |
Date: |
Fri, 1 Dec 2023 12:15:33 -0500 |
From: Philippe Mathieu-Daudé <philmd@linaro.org>
erst_realizefn() passes @errp to functions without checking for
failure. If it runs into another failure, it trips error_setv()'s
assertion.
Use the ERRP_GUARD() macro and check *errp, as suggested in commit
ae7c80a7bd ("error: New macro ERRP_GUARD()").
Cc: qemu-stable@nongnu.org
Fixes: f7e26ffa59 ("ACPI ERST: support for ACPI ERST feature")
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-Id: <20231120130017.81286-1-philmd@linaro.org>
Reviewed-by: Ani Sinha <anisinha@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/acpi/erst.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/hw/acpi/erst.c b/hw/acpi/erst.c
index 35007d8017..ba751dc60e 100644
--- a/hw/acpi/erst.c
+++ b/hw/acpi/erst.c
@@ -947,6 +947,7 @@ static const VMStateDescription erst_vmstate = {
static void erst_realizefn(PCIDevice *pci_dev, Error **errp)
{
+ ERRP_GUARD();
ERSTDeviceState *s = ACPIERST(pci_dev);
trace_acpi_erst_realizefn_in();
@@ -964,9 +965,15 @@ static void erst_realizefn(PCIDevice *pci_dev, Error
**errp)
/* HostMemoryBackend size will be multiple of PAGE_SIZE */
s->storage_size = object_property_get_int(OBJECT(s->hostmem), "size",
errp);
+ if (*errp) {
+ return;
+ }
/* Initialize backend storage and record_count */
check_erst_backend_storage(s, errp);
+ if (*errp) {
+ return;
+ }
/* BAR 0: Programming registers */
memory_region_init_io(&s->iomem_mr, OBJECT(pci_dev), &erst_reg_ops, s,
@@ -977,6 +984,9 @@ static void erst_realizefn(PCIDevice *pci_dev, Error **errp)
memory_region_init_ram(&s->exchange_mr, OBJECT(pci_dev),
"erst.exchange",
le32_to_cpu(s->header->record_size), errp);
+ if (*errp) {
+ return;
+ }
pci_register_bar(pci_dev, 1, PCI_BASE_ADDRESS_SPACE_MEMORY,
&s->exchange_mr);
--
MST
- [PULL 04/15] hw/audio/virtio-snd-pci: fix the PCI class code, (continued)
- [PULL 04/15] hw/audio/virtio-snd-pci: fix the PCI class code, Michael S. Tsirkin, 2023/12/01
- [PULL 05/15] hw/audio/hda-codec: fix multiplication overflow, Michael S. Tsirkin, 2023/12/01
- [PULL 01/15] osdep: add getloadavg, Michael S. Tsirkin, 2023/12/01
- [PULL 07/15] virtio-snd: check AUD_register_card return value, Michael S. Tsirkin, 2023/12/01
- [PULL 15/15] vhost-user-scsi: free the inflight area when reset, Michael S. Tsirkin, 2023/12/01
- [PULL 02/15] netdev: set timeout depending on loadavg, Michael S. Tsirkin, 2023/12/01
- [PULL 03/15] tests/acpi/bios-tables-test: do not write new blobs unless there are changes, Michael S. Tsirkin, 2023/12/01
- [PULL 09/15] pcie_sriov: Remove g_new assertion, Michael S. Tsirkin, 2023/12/01
- [PULL 10/15] hw/acpi/erst: Do not ignore Error* in realize handler,
Michael S. Tsirkin <=
- [PULL 12/15] virtio-iommu: Remove useless !sdev check in virtio_iommu_probe(), Michael S. Tsirkin, 2023/12/01
- [PULL 08/15] virtio-sound: add realize() error cleanup path, Michael S. Tsirkin, 2023/12/01
- [PULL 14/15] vhost-user: fix the reconnect error, Michael S. Tsirkin, 2023/12/01
- [PULL 13/15] msix: unset PCIDevice::msix_vector_poll_notifier in rollback, Michael S. Tsirkin, 2023/12/01
- [PULL 06/15] hw/audio/hda-codec: reenable the audio mixer, Michael S. Tsirkin, 2023/12/01
- [PULL 11/15] hw/i386: fix short-circuit logic with non-optimizing builds, Michael S. Tsirkin, 2023/12/01
- Re: [PULL 00/15] virtio,pc,pci: fixes, Michael S. Tsirkin, 2023/12/02
- Re: [PULL 00/15] virtio,pc,pci: fixes, Stefan Hajnoczi, 2023/12/04