summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2007-03-06 10:48:51 -0800
committerEric Anholt <eric@anholt.net>2007-03-06 10:48:51 -0800
commitb36d737d92dbeee7951aded990fa52bac39b2a79 (patch)
treec2a8f1a554a4dec3f9d81b55156797e4c79ba272 /src
parent09be109c223b93d74ea3cc7a12d9a22b44990a14 (diff)
downloadlibpciaccess-b36d737d92dbeee7951aded990fa52bac39b2a79.tar.gz
libpciaccess-b36d737d92dbeee7951aded990fa52bac39b2a79.tar.bz2
libpciaccess-b36d737d92dbeee7951aded990fa52bac39b2a79.zip
FreeBSD: Fix a couple of minor issues in cleanup paths.
Diffstat (limited to 'src')
-rw-r--r--src/freebsd_pci.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/freebsd_pci.c b/src/freebsd_pci.c
index a4a8f44..751298d 100644
--- a/src/freebsd_pci.c
+++ b/src/freebsd_pci.c
@@ -51,6 +51,9 @@
* It is initialized once and used as a global, just as pci_system is used.
*/
struct freebsd_pci_system {
+ /* This must be the first entry in the structure, as pci_system_cleanup()
+ * frees pci_sys.
+ */
struct pci_system pci_sys;
int pcidev; /**< fd for /dev/pci */
@@ -82,6 +85,7 @@ pci_device_freebsd_map( struct pci_device *dev, unsigned region,
dev->regions[ region ].base_addr);
if ( dev->regions[ region ].memory == MAP_FAILED ) {
+ close( fd );
dev->regions[ region ].memory = NULL;
err = errno;
}
@@ -320,17 +324,16 @@ pci_device_freebsd_probe( struct pci_device * dev )
}
static void
-pci_system_freebsd_destroy()
+pci_system_freebsd_destroy(void)
{
close(freebsd_pci_sys->pcidev);
free(freebsd_pci_sys->pci_sys.devices);
- free(freebsd_pci_sys);
freebsd_pci_sys = NULL;
}
static const struct pci_system_methods freebsd_pci_methods = {
.destroy = pci_system_freebsd_destroy,
- .destroy_device = NULL,
+ .destroy_device = NULL, /* nothing to do for this */
.read_rom = NULL, /* XXX: Fill me in */
.probe = pci_device_freebsd_probe,
.map = pci_device_freebsd_map,