提交 d18aa704 编写于 作者: C Chen Hanxiao 提交者: Laine Stump

util: fix memory leak in failure path of virCgroupKillRecursiveInternal

Don't leak keypath when we fail to kill a process
Signed-off-by: NChen Hanxiao <chenhanxiao@cn.fujitsu.com>
上级 b279e52f
...@@ -3370,7 +3370,7 @@ virCgroupKillRecursiveInternal(virCgroupPtr group, ...@@ -3370,7 +3370,7 @@ virCgroupKillRecursiveInternal(virCgroupPtr group,
int rc; int rc;
bool killedAny = false; bool killedAny = false;
char *keypath = NULL; char *keypath = NULL;
DIR *dp; DIR *dp = NULL;
virCgroupPtr subgroup = NULL; virCgroupPtr subgroup = NULL;
struct dirent *ent; struct dirent *ent;
int direrr; int direrr;
...@@ -3381,7 +3381,7 @@ virCgroupKillRecursiveInternal(virCgroupPtr group, ...@@ -3381,7 +3381,7 @@ virCgroupKillRecursiveInternal(virCgroupPtr group,
return -1; return -1;
if ((rc = virCgroupKillInternal(group, signum, pids)) < 0) if ((rc = virCgroupKillInternal(group, signum, pids)) < 0)
return -1; goto cleanup;
if (rc == 1) if (rc == 1)
killedAny = true; killedAny = true;
...@@ -3394,7 +3394,7 @@ virCgroupKillRecursiveInternal(virCgroupPtr group, ...@@ -3394,7 +3394,7 @@ virCgroupKillRecursiveInternal(virCgroupPtr group,
} }
virReportSystemError(errno, virReportSystemError(errno,
_("Cannot open %s"), keypath); _("Cannot open %s"), keypath);
return -1; goto cleanup;
} }
while ((direrr = virDirRead(dp, &ent, keypath)) > 0) { while ((direrr = virDirRead(dp, &ent, keypath)) > 0) {
...@@ -3429,7 +3429,9 @@ virCgroupKillRecursiveInternal(virCgroupPtr group, ...@@ -3429,7 +3429,9 @@ virCgroupKillRecursiveInternal(virCgroupPtr group,
cleanup: cleanup:
virCgroupFree(&subgroup); virCgroupFree(&subgroup);
closedir(dp); VIR_FREE(keypath);
if (dp)
closedir(dp);
return ret; return ret;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册