[PATCH] Make sure that filedescriptors are only closed once

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>

---
 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:

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]