From 10af0a19736aa200170eec52a1e1befa73885a6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1n=20Tomko?= Date: Mon, 23 Jun 2014 08:58:27 +0200 Subject: [PATCH] Do not call closedir with NULL argument 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 4dbaed18ca..53bcfcb32b 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 9a0205ff88..9f5cf0daa1 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; } -- GitLab