]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
node_device_linux_sysfs.c: avoid opendir/fd leak on error path
authorJim Meyering <meyering@redhat.com>
Wed, 20 Jan 2010 16:49:35 +0000 (17:49 +0100)
committerJim Meyering <meyering@redhat.com>
Wed, 20 Jan 2010 20:52:51 +0000 (21:52 +0100)
* src/node_device/node_device_linux_sysfs.c(get_virtual_functions_linux):
Don't leak a DIR buffer and file descriptor on error path.

src/node_device/node_device_linux_sysfs.c

index ff7aaf09a7feaed2c1d1afbb19531fad54c824cd..674ee2660da82b6792254b749e95fadc7e444944 100644 (file)
@@ -2,7 +2,7 @@
  * node_device_hal_linuc.c: Linux specific code to gather device data
  * not available through HAL.
  *
- * Copyright (C) 2009 Red Hat, Inc.
+ * Copyright (C) 2009-2010 Red Hat, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -367,10 +367,13 @@ int get_virtual_functions_linux(const char *sysfs_path,
     }
 
     closedir(dir);
+    dir = NULL;
 
     ret = 0;
 
 out:
+    if (dir)
+        closedir(dir);
     VIR_FREE(device_link);
     return 0;
 }