mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-24 22:55:23 +00:00
parallels: fix leaks in parallelsFindVolumes
We always have to close opened dir and free 'path'. Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
This commit is contained in:
parent
766e0c91d7
commit
7abe342d96
@ -86,13 +86,14 @@ parallelsFindVolumes(virStoragePoolObjPtr pool)
|
|||||||
{
|
{
|
||||||
DIR *dir;
|
DIR *dir;
|
||||||
struct dirent *ent;
|
struct dirent *ent;
|
||||||
char *path;
|
char *path = NULL;
|
||||||
|
int ret = -1;
|
||||||
|
|
||||||
if (!(dir = opendir(pool->def->target.path))) {
|
if (!(dir = opendir(pool->def->target.path))) {
|
||||||
virReportSystemError(errno,
|
virReportSystemError(errno,
|
||||||
_("cannot open path '%s'"),
|
_("cannot open path '%s'"),
|
||||||
pool->def->target.path);
|
pool->def->target.path);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((ent = readdir(dir)) != NULL) {
|
while ((ent = readdir(dir)) != NULL) {
|
||||||
@ -100,18 +101,21 @@ parallelsFindVolumes(virStoragePoolObjPtr pool)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!(path = virFileBuildPath(pool->def->target.path,
|
if (!(path = virFileBuildPath(pool->def->target.path,
|
||||||
ent->d_name, NULL)))
|
ent->d_name, NULL))) {
|
||||||
goto no_memory;
|
virReportOOMError();
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
if (!parallelsStorageVolumeDefine(pool, NULL, path, false))
|
if (!parallelsStorageVolumeDefine(pool, NULL, path, false))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
VIR_FREE(path);
|
VIR_FREE(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
ret = 0;
|
||||||
no_memory:
|
|
||||||
virReportOOMError();
|
|
||||||
cleanup:
|
cleanup:
|
||||||
return -1;
|
VIR_FREE(path);
|
||||||
|
closedir(dir);
|
||||||
|
return ret;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user