*** pci.c.orig Sun Oct 23 15:31:23 2005 --- pci.c Sun Oct 23 19:02:46 2005 *************** *** 984,989 **** --- 984,990 ---- int maxslots; int s, f, pcifunchigh; uint8_t hdrtype; + uint16_t vendor; KASSERT(dinfo_size >= sizeof(struct pci_devinfo), ("dinfo_size too small")); *************** *** 991,996 **** --- 992,1006 ---- for (s = 0; s <= maxslots; s++) { pcifunchigh = 0; f = 0; + /* + * To verify if there's actually a device + * at this offset, check the vendor ID + * field in the device/vendor register first. + */ + vendor = REG(PCIR_VENDOR, 2); + if (vendor == 0xFFFF || vendor == 0) + continue; + /* Now check if it's multifunction. */ hdrtype = REG(PCIR_HDRTYPE, 1); if ((hdrtype & PCIM_HDRTYPE) > PCI_MAXHDRTYPE) continue;