summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNithin Nayak Sujir <nsujir@broadcom.com>2011-10-24 12:15:15 -0700
committerJeremy Huddleston <jeremyhu@apple.com>2011-10-24 22:40:37 -0700
commita0a53a67c91c698007dcac3e7aba27c999c4f6ed (patch)
tree21f9b910be7bab56877df58205a21a35520f5b55
parent803bf3aa28de0f1260e479e2036159d4fead0a87 (diff)
libpciaccess: close mtrr fd on pci_cleanup
Since the fd is not closed, calling pci_system_init and pci_system_cleanup more than 1024 times results in "too many files open" error. Signed-off-by: Nithin Nayak Sujir <nsujir@broadcom.com> Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
-rw-r--r--src/linux_sysfs.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/linux_sysfs.c b/src/linux_sysfs.c
index d5ba66a..09e7138 100644
--- a/src/linux_sysfs.c
+++ b/src/linux_sysfs.c
@@ -889,8 +889,18 @@ pci_device_linux_sysfs_unmap_legacy(struct pci_device *dev, void *addr, pciaddr_
return munmap(addr, size);
}
+
+static void
+pci_system_linux_destroy(void)
+{
+#ifdef HAVE_MTRR
+ if (pci_sys->mtrr_fd != -1)
+ close(pci_sys->mtrr_fd);
+#endif
+}
+
static const struct pci_system_methods linux_sysfs_methods = {
- .destroy = NULL,
+ .destroy = pci_system_linux_destroy,
.destroy_device = NULL,
.read_rom = pci_device_linux_sysfs_read_rom,
.probe = pci_device_linux_sysfs_probe,