diff --git a/src/openvz_conf.c b/src/openvz_conf.c index 41c668473cec38e03e60c805258fbedb9f44b7fe..820a4ecb32970037e8fdfa6afb087c6ff302d270 100644 --- a/src/openvz_conf.c +++ b/src/openvz_conf.c @@ -822,8 +822,10 @@ openvzGetVPSUUID(int vpsid, char *uuidstr, size_t len) while(1) { ret = openvz_readline(fd, line, sizeof(line)); - if(ret == -1) + if(ret == -1) { + close(fd); return -1; + } if(ret == 0) { /* EoF, UUID was not found */ uuidstr[0] = 0; diff --git a/src/qemu_driver.c b/src/qemu_driver.c index 2a8e6d161395a16fd605ef8987bf954a6359f687..f64d70bd1b390777fb0dbc0d0cbeb4fab14c3402 100644 --- a/src/qemu_driver.c +++ b/src/qemu_driver.c @@ -2837,6 +2837,7 @@ static int qemudGetProcessInfo(unsigned long long *cpuTime, int *lastCpu, int pi /* startstack -> processor */ "%*u %*u %*u %*u %*u %*u %*u %*u %*u %*u %*d %d", &usertime, &systime, &cpu) != 3) { + fclose(pidinfo); VIR_WARN0("cannot parse process status data"); errno = -EINVAL; return -1; diff --git a/src/storage_backend_scsi.c b/src/storage_backend_scsi.c index 1d2378b5b2374e040358869a3546c0c26df093fb..a09103fd292a90d98f1534ce4cd5e9ddb307b97c 100644 --- a/src/storage_backend_scsi.c +++ b/src/storage_backend_scsi.c @@ -137,7 +137,7 @@ virStorageBackendSCSIUpdateVolTargetInfo(virConnectPtr conn, unsigned long long *allocation, unsigned long long *capacity) { - int fd, i; + int fd, i, ret = -1; off_t start; unsigned char buffer[1024]; ssize_t bytes; @@ -154,7 +154,7 @@ virStorageBackendSCSIUpdateVolTargetInfo(virConnectPtr conn, fd, allocation, capacity) < 0) - return -1; + goto cleanup; /* make sure to set the target format "unknown" to begin with */ target->format = VIR_STORAGE_POOL_DISK_UNKNOWN; @@ -164,14 +164,14 @@ virStorageBackendSCSIUpdateVolTargetInfo(virConnectPtr conn, virReportSystemError(conn, errno, _("cannot seek to beginning of file '%s'"), target->path); - return -1; + goto cleanup; } bytes = saferead(fd, buffer, sizeof(buffer)); if (bytes < 0) { virReportSystemError(conn, errno, _("cannot read beginning of file '%s'"), target->path); - return -1; + goto cleanup; } for (i = 0; disk_types[i].part_table_type != -1; i++) { @@ -184,7 +184,12 @@ virStorageBackendSCSIUpdateVolTargetInfo(virConnectPtr conn, } } - return 0; + ret = 0; + + cleanup: + close(fd); + + return ret; } static int diff --git a/src/xen_inotify.c b/src/xen_inotify.c index f4716ca405cc8c623e0f0abb6cceb1a00aea8cc5..e312b9eb1c682cfd10357fb89c3780a3f04bcdde 100644 --- a/src/xen_inotify.c +++ b/src/xen_inotify.c @@ -424,6 +424,7 @@ xenInotifyOpen(virConnectPtr conn ATTRIBUTE_UNUSED, if (xenInotifyAddDomainConfigInfo(conn, path) < 0 ) { virXenInotifyError(NULL, VIR_ERR_INTERNAL_ERROR, "%s", _("Error adding file to config list")); + closedir(dh); return -1; } }