diff options
author | Matthieu Herrb <matthieu@herrb.eu> | 2024-05-05 20:49:31 +0200 |
---|---|---|
committer | Matthieu Herrb <matthieu@herrb.eu> | 2024-05-05 20:49:31 +0200 |
commit | 3cb4d40f88479bbcc994543327a0505ce8b54ee0 (patch) | |
tree | dc689e65fb7fa7e03bf2223feb1ada615723d2b3 | |
parent | 5ff043322ae4e5df25a1a9b6495c0f56d5168584 (diff) |
fix small leaks in openbsd_pci.c
-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; } |