diff options
Diffstat (limited to 'pci.c')
-rw-r--r-- | pci.c | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -56,6 +56,7 @@ extern struct pciusb_entries pci_probe(void) { static struct pci_access *pacc; struct pci_dev *dev; char classbuf[128], vendorbuf[128], devbuf[128]; + size_t allocated = MAX_DEVICES; r.nb = 0; if ((access(proc_pci_path_default, R_OK) != 0) @@ -76,8 +77,11 @@ extern struct pciusb_entries pci_probe(void) { r.nb = 0; r.entries = malloc(sizeof(struct pciusb_entry) * MAX_DEVICES); - for (dev = pacc->devices; dev && r.nb < MAX_DEVICES; dev = dev->next, r.nb++) { - + for (dev = pacc->devices; dev; dev = dev->next, r.nb++) { + if (r.nb >= allocated) { + allocated = r.nb*2; + r.entries = realloc(r.entries, sizeof(struct pciusb_entry) * allocated); + } struct pciusb_entry *e = &r.entries[r.nb]; memset(buf, 0, CONFIG_SPACE_SIZE); // make sure not to retrieve values from previous devices pci_setup_cache(dev, (u8*)buf, CONFIG_SPACE_SIZE); |