From 3cb4d40f88479bbcc994543327a0505ce8b54ee0 Mon Sep 17 00:00:00 2001 From: Matthieu Herrb Date: Sun, 5 May 2024 20:49:31 +0200 Subject: fix small leaks in openbsd_pci.c --- src/openbsd_pci.c | 12 ++++++------ 1 file 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; } -- cgit v1.2.3