[libvirt] [PATCH] Make sure that filedescriptors are only closed once

Stefan Berger stefanb at linux.vnet.ibm.com
Fri Oct 15 01:20:01 UTC 2010


  Setting fd=-1 in these places makes sure that the fd is not closed 
twice later on in 'clean:'. This is of course a recipe for disaster in a 
multi-threaded system where the filedescriptor can belong to something 
else right away.
At least we have a pattern...

(looks like I can close the augeas bug as well...)

Signed-off-by: Stefan Berger <stefanb at us.ibm.com>

---
  src/conf/domain_conf.c   |    2 ++
  src/conf/network_conf.c  |    2 ++
  src/conf/nwfilter_conf.c |    4 ++++
  src/conf/storage_conf.c  |    2 ++
  4 files changed, 10 insertions(+)

Index: libvirt-acl/src/conf/domain_conf.c
===================================================================
--- libvirt-acl.orig/src/conf/domain_conf.c
+++ libvirt-acl/src/conf/domain_conf.c
@@ -6805,6 +6805,8 @@ int virDomainSaveXML(const char *configD
          goto cleanup;
      }

+    fd = -1;
+
      ret = 0;
   cleanup:
      if (fd != -1)
Index: libvirt-acl/src/conf/network_conf.c
===================================================================
--- libvirt-acl.orig/src/conf/network_conf.c
+++ libvirt-acl/src/conf/network_conf.c
@@ -694,6 +694,8 @@ int virNetworkSaveXML(const char *config
          goto cleanup;
      }

+    fd = -1;
+
      ret = 0;

   cleanup:
Index: libvirt-acl/src/conf/nwfilter_conf.c
===================================================================
--- libvirt-acl.orig/src/conf/nwfilter_conf.c
+++ libvirt-acl/src/conf/nwfilter_conf.c
@@ -2200,6 +2200,8 @@ int virNWFilterSaveXML(const char *confi
          goto cleanup;
      }

+    fd = -1;
+
      ret = 0;

   cleanup:
@@ -2611,6 +2613,8 @@ virNWFilterPoolObjSaveDef(virNWFilterDri
          goto cleanup;
      }

+    fd = -1;
+
      ret = 0;

   cleanup:
Index: libvirt-acl/src/conf/storage_conf.c
===================================================================
--- libvirt-acl.orig/src/conf/storage_conf.c
+++ libvirt-acl/src/conf/storage_conf.c
@@ -1567,6 +1567,8 @@ virStoragePoolObjSaveDef(virStorageDrive
          goto cleanup;
      }

+    fd = -1;
+
      ret = 0;

   cleanup:




More information about the libvir-list mailing list