aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Piggin <npiggin@gmail.com>2025-01-18 03:28:41 +1000
committerMichael S. Tsirkin <mst@redhat.com>2025-02-21 07:18:09 -0500
commitf6fc01c7866639649b9af58ad50a7367b2d18eae (patch)
tree5cf0596c04639e2901433149bb7ad36c1c950ba5
parent44ed44aefec571041fe3b3a8b6849613a74b520a (diff)
downloadqemu-f6fc01c7866639649b9af58ad50a7367b2d18eae.zip
qemu-f6fc01c7866639649b9af58ad50a7367b2d18eae.tar.gz
qemu-f6fc01c7866639649b9af58ad50a7367b2d18eae.tar.bz2
hw/pci: Assert a bar is not registered multiple times
Nothing should be doing this, but it doesn't get caught by pci_register_bar(). Add an assertion to prevent misuse. Signed-off-by: Nicholas Piggin <npiggin@gmail.com> Message-Id: <20250117172842.406338-3-npiggin@gmail.com> Reviewed-by: Phil Dennis-Jordan <phil@philjordan.eu> Signed-off-by: Nicholas Piggin <npiggin@gmail.com> Reviewed-by: Phil Dennis-Jordan <phil@philjordan.eu> Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
-rw-r--r--hw/pci/pci.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index 69a1b8c..1d42847 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -1398,6 +1398,7 @@ void pci_register_bar(PCIDevice *pci_dev, int region_num,
assert(hdr_type != PCI_HEADER_TYPE_BRIDGE || region_num < 2);
r = &pci_dev->io_regions[region_num];
+ assert(!r->size);
r->addr = PCI_BAR_UNMAPPED;
r->size = size;
r->type = type;