This 'used' array is allocated via:

 pci_qdev_realize() -> do_pci_register_device() -> pci_config_alloc()

In a perfect world where all device models are correctly QOM'ified
this can't happen. Still it occured to me while refactoring QDev and
it was not obvious to figure out. This assert helped, so keep it.

Signed-off-by: Philippe Mathieu-Daudé <phi...@linaro.org>
---
 hw/pci/pci.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index def5000e7b..ac41fcbf6a 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -2185,6 +2185,7 @@ static uint8_t pci_find_space(PCIDevice *pdev, uint8_t 
size)
 {
     int offset = PCI_CONFIG_HEADER_SIZE;
     int i;
+    assert(pdev->used);
     for (i = PCI_CONFIG_HEADER_SIZE; i < PCI_CONFIG_SPACE_SIZE; ++i) {
         if (pdev->used[i])
             offset = i + 1;
-- 
2.38.1


Reply via email to