summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/libpciaccess/src/openbsd_pci.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/libpciaccess/src/openbsd_pci.c b/lib/libpciaccess/src/openbsd_pci.c
index 5c06b4743..7bb20d6e5 100644
--- a/lib/libpciaccess/src/openbsd_pci.c
+++ b/lib/libpciaccess/src/openbsd_pci.c
@@ -33,7 +33,7 @@
#include "pciaccess.h"
#include "pciaccess_private.h"
-static int pcifd;
+static int pcifd = -1;
static int aperturefd = -1;
static int
@@ -216,6 +216,8 @@ pci_system_openbsd_destroy(void)
{
close(aperturefd);
close(pcifd);
+ aperturefd = -1;
+ pcifd = -1;
free(pci_sys);
pci_sys = NULL;
}
@@ -318,6 +320,9 @@ pci_system_openbsd_create(void)
int bus, dev, func, ndevs, nfuncs;
uint32_t reg;
+ if (pcifd != -1)
+ return 0;
+
pcifd = open("/dev/pci", O_RDWR);
if (pcifd == -1)
return ENXIO;