[PATCH] libpciaccess: close mtrr fd on pci_cleanup

Nithin Nayak Sujir nsujir at broadcom.com
Fri Oct 21 11:49:19 PDT 2011


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 at broadcom.com>
---
 src/common_init.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/src/common_init.c b/src/common_init.c
index 5e91c27..d7ade3f 100644
--- a/src/common_init.c
+++ b/src/common_init.c
@@ -31,7 +31,9 @@
 
 #include <stdlib.h>
 #include <errno.h>
+#include <unistd.h>
 
+#include "config.h"
 #include "pciaccess.h"
 #include "pciaccess_private.h"
 
@@ -122,6 +124,10 @@ pci_system_cleanup( void )
 	(*pci_sys->methods->destroy)();
     }
 
+#ifdef HAVE_MTRR
+    if (pci_sys->mtrr_fd != -1)
+	    close(pci_sys->mtrr_fd);
+#endif
     free( pci_sys );
     pci_sys = NULL;
 }
-- 
1.7.1





More information about the xorg mailing list