]> xenbits.xensource.com Git - libvirt.git/commitdiff
Do not call closedir with NULL argument
authorJán Tomko <jtomko@redhat.com>
Mon, 23 Jun 2014 06:58:27 +0000 (08:58 +0200)
committerJán Tomko <jtomko@redhat.com>
Mon, 23 Jun 2014 12:16:23 +0000 (14:16 +0200)
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
src/util/virscsi.c

index 4dbaed18caa5bd19749e77cac229c520ce7b2cc5..53bcfcb32b86484f2d6b1ea669241ab6f55b87ab 100644 (file)
@@ -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) {
index 9a0205ff886a55836de249c5a29180eea48d0a79..9f5cf0daa1afe4edc271add1aa976d3ecbf099eb 100644 (file)
@@ -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;
 }