[PATCH] Do not call closedir with NULL argument

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

 



Only three other callers possibly call closedir on a NULL argument.
Even though these probably won't be used on FreeBSD where this crashes,
let's be nice and only call closedir on an actual directory stream.
---
 src/parallels/parallels_storage.c | 2 +-
 src/util/virscsi.c                | 6 ++++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/parallels/parallels_storage.c b/src/parallels/parallels_storage.c
index 4dbaed1..53bcfcb 100644
--- a/src/parallels/parallels_storage.c
+++ b/src/parallels/parallels_storage.c
@@ -340,7 +340,7 @@ static int parallelsFindVmVolumes(virStoragePoolObjPtr pool,
         virReportSystemError(errno,
                              _("cannot open path '%s'"),
                              pdom->home);
-        goto cleanup;
+        return ret;
     }
 
     while ((direrr = virDirRead(dir, &ent, pdom->home)) > 0) {
diff --git a/src/util/virscsi.c b/src/util/virscsi.c
index 9a0205f..9f5cf0d 100644
--- a/src/util/virscsi.c
+++ b/src/util/virscsi.c
@@ -143,7 +143,8 @@ virSCSIDeviceGetSgName(const char *sysfs_prefix,
     }
 
  cleanup:
-    closedir(dir);
+    if (dir)
+        closedir(dir);
     VIR_FREE(path);
     return sg;
 }
@@ -188,7 +189,8 @@ virSCSIDeviceGetDevName(const char *sysfs_prefix,
     }
 
  cleanup:
-    closedir(dir);
+    if (dir)
+        closedir(dir);
     VIR_FREE(path);
     return name;
 }
-- 
1.8.5.5

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