WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] xend: pci.py: fix open file descriptor le

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] xend: pci.py: fix open file descriptor leak
From: Xen patchbot-unstable <patchbot@xxxxxxx>
Date: Thu, 20 Jan 2011 19:05:12 -0800
Delivery-date: Thu, 20 Jan 2011 19:05:31 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Kouya Shimura <kouya@xxxxxxxxxxxxxx>
# Date 1295541683 0
# Node ID 3a89585d77b1c1c5b795efc247d3648233872938
# Parent  0592d6ca9177179f5a2724baa7598b3317415da3
xend: pci.py: fix open file descriptor leak

I got the following error:
    $ xm pci-list-assignable-devices
    Error: [Errno 24] Too many open files

Signed-off-by: Kouya Shimura <kouya@xxxxxxxxxxxxxx>
---
 tools/python/xen/util/pci.py |    4 ++++
 1 files changed, 4 insertions(+)

diff -r 0592d6ca9177 -r 3a89585d77b1 tools/python/xen/util/pci.py
--- a/tools/python/xen/util/pci.py      Thu Jan 20 16:32:33 2011 +0000
+++ b/tools/python/xen/util/pci.py      Thu Jan 20 16:41:23 2011 +0000
@@ -922,10 +922,12 @@ class PciDevice:
         pos = PCI_CAPABILITY_LIST
 
         try:
+            fd = None
             fd = os.open(path, os.O_RDONLY)
             os.lseek(fd, PCI_STATUS, 0)
             status = struct.unpack('H', os.read(fd, 2))[0]
             if (status & 0x10) == 0:
+                os.close(fd)
                 # The device doesn't support PCI_STATUS_CAP_LIST
                 return 0
 
@@ -952,6 +954,8 @@ class PciDevice:
 
             os.close(fd)
         except OSError, (errno, strerr):
+            if fd is not None:
+                os.close(fd)
             raise PciDeviceParseError(('Error when accessing sysfs: %s (%d)' %
                 (strerr, errno)))
         return pos

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] xend: pci.py: fix open file descriptor leak, Xen patchbot-unstable <=