Don't leak keypath when we fail to kill a process
Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
int rc;
bool killedAny = false;
char *keypath = NULL;
- DIR *dp;
+ DIR *dp = NULL;
virCgroupPtr subgroup = NULL;
struct dirent *ent;
int direrr;
return -1;
if ((rc = virCgroupKillInternal(group, signum, pids)) < 0)
- return -1;
+ goto cleanup;
if (rc == 1)
killedAny = true;
}
virReportSystemError(errno,
_("Cannot open %s"), keypath);
- return -1;
+ goto cleanup;
}
while ((direrr = virDirRead(dp, &ent, keypath)) > 0) {
cleanup:
virCgroupFree(&subgroup);
- closedir(dp);
+ VIR_FREE(keypath);
+ if (dp)
+ closedir(dp);
return ret;
}