diff options
-rw-r--r-- | src/openbsd_pci.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/openbsd_pci.c b/src/openbsd_pci.c index 5582058..9e6717d 100644 --- a/src/openbsd_pci.c +++ b/src/openbsd_pci.c @@ -337,6 +337,8 @@ pci_system_openbsd_destroy(void) for (domain = 0; domain < ndomains; domain++) close(pcifd[domain]); ndomains = 0; + free(pci_sys); + pci_sys = NULL; } static int @@ -645,8 +647,10 @@ pci_system_openbsd_create(void) ndomains++; } - if (ndomains == 0) + if (ndomains == 0) { + pci_system_openbsd_destroy(); return ENXIO; + } ndevs = 0; for (domain = 0; domain < ndomains; domain++) { @@ -670,11 +674,7 @@ pci_system_openbsd_create(void) pci_sys->num_devices = ndevs; pci_sys->devices = calloc(ndevs, sizeof(struct pci_device_private)); if (pci_sys->devices == NULL) { - free(pci_sys); - pci_sys = NULL; - for (domain = 0; domain < ndomains; domain++) - close(pcifd[domain]); - ndomains = 0; + pci_system_openbsd_destroy(); return ENOMEM; } |