On Thu, Jan 09, 2020 at 03:43:10PM +0100, Eric Auger wrote: > +/** > + * The bus number is used for lookup when SID based operations occur. > + * In that case we lazily populate the IOMMUPciBus array from the bus hash > + * table. At the time the IOMMUPciBus is created (iommu_find_add_as), the bus > + * numbers may not be always initialized yet. > + */ > +static IOMMUPciBus *iommu_find_iommu_pcibus(VirtIOIOMMU *s, uint8_t bus_num) > +{ > + IOMMUPciBus *iommu_pci_bus = s->iommu_pcibus_by_bus_num[bus_num]; > + > + if (!iommu_pci_bus) { > + GHashTableIter iter; > + > + g_hash_table_iter_init(&iter, s->as_by_busptr); > + while (g_hash_table_iter_next(&iter, NULL, (void **)&iommu_pci_bus)) > { > + if (pci_bus_num(iommu_pci_bus->bus) == bus_num) { > + s->iommu_pcibus_by_bus_num[bus_num] = iommu_pci_bus; > + return iommu_pci_bus; > + } > + }
Btw, we may need to: return NULL; here. > + } > + return iommu_pci_bus; > +} -- Peter Xu