Re: [libvirt] [PATCH] vircgroup: Don't leak keypath if failed to kill process
ping -Original Message- From: Chen, Hanxiao/陈 晗霄 Sent: Tuesday, May 13, 2014 4:01 PM To: libvir-list@redhat.com Cc: Chen, Hanxiao/陈 晗霄 Subject: [libvirt][PATCH] vircgroup: Don't leak keypath if failed to kill process Signed-off-by: Chen Hanxiao chenhanx...@cn.fujitsu.com --- src/util/vircgroup.c | 10 ++ 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index fce380a..c578bd0 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -3370,7 +3370,7 @@ virCgroupKillRecursiveInternal(virCgroupPtr group, int rc; bool killedAny = false; char *keypath = NULL; -DIR *dp; +DIR *dp = NULL; virCgroupPtr subgroup = NULL; struct dirent *ent; int direrr; @@ -3381,7 +3381,7 @@ virCgroupKillRecursiveInternal(virCgroupPtr group, return -1; if ((rc = virCgroupKillInternal(group, signum, pids)) 0) -return -1; +goto cleanup; if (rc == 1) killedAny = true; @@ -3394,7 +3394,7 @@ virCgroupKillRecursiveInternal(virCgroupPtr group, } virReportSystemError(errno, _(Cannot open %s), keypath); -return -1; +goto cleanup; } while ((direrr = virDirRead(dp, ent, keypath)) 0) { @@ -3429,7 +3429,9 @@ virCgroupKillRecursiveInternal(virCgroupPtr group, cleanup: virCgroupFree(subgroup); -closedir(dp); +VIR_FREE(keypath); +if (dp) +closedir(dp); return ret; } -- 1.9.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] vircgroup: Don't leak keypath if failed to kill process
On 05/13/2014 11:01 AM, Chen Hanxiao wrote: Signed-off-by: Chen Hanxiao chenhanx...@cn.fujitsu.com --- src/util/vircgroup.c | 10 ++ 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index fce380a..c578bd0 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -3370,7 +3370,7 @@ virCgroupKillRecursiveInternal(virCgroupPtr group, int rc; bool killedAny = false; char *keypath = NULL; -DIR *dp; +DIR *dp = NULL; virCgroupPtr subgroup = NULL; struct dirent *ent; int direrr; @@ -3381,7 +3381,7 @@ virCgroupKillRecursiveInternal(virCgroupPtr group, return -1; if ((rc = virCgroupKillInternal(group, signum, pids)) 0) -return -1; +goto cleanup; if (rc == 1) killedAny = true; @@ -3394,7 +3394,7 @@ virCgroupKillRecursiveInternal(virCgroupPtr group, } virReportSystemError(errno, _(Cannot open %s), keypath); -return -1; +goto cleanup; } while ((direrr = virDirRead(dp, ent, keypath)) 0) { @@ -3429,7 +3429,9 @@ virCgroupKillRecursiveInternal(virCgroupPtr group, cleanup: virCgroupFree(subgroup); -closedir(dp); +VIR_FREE(keypath); +if (dp) +closedir(dp); return ret; } ACK and pushed (with small change to commit log message) -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] vircgroup: Don't leak keypath if failed to kill process
Signed-off-by: Chen Hanxiao chenhanx...@cn.fujitsu.com --- src/util/vircgroup.c | 10 ++ 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index fce380a..c578bd0 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -3370,7 +3370,7 @@ virCgroupKillRecursiveInternal(virCgroupPtr group, int rc; bool killedAny = false; char *keypath = NULL; -DIR *dp; +DIR *dp = NULL; virCgroupPtr subgroup = NULL; struct dirent *ent; int direrr; @@ -3381,7 +3381,7 @@ virCgroupKillRecursiveInternal(virCgroupPtr group, return -1; if ((rc = virCgroupKillInternal(group, signum, pids)) 0) -return -1; +goto cleanup; if (rc == 1) killedAny = true; @@ -3394,7 +3394,7 @@ virCgroupKillRecursiveInternal(virCgroupPtr group, } virReportSystemError(errno, _(Cannot open %s), keypath); -return -1; +goto cleanup; } while ((direrr = virDirRead(dp, ent, keypath)) 0) { @@ -3429,7 +3429,9 @@ virCgroupKillRecursiveInternal(virCgroupPtr group, cleanup: virCgroupFree(subgroup); -closedir(dp); +VIR_FREE(keypath); +if (dp) +closedir(dp); return ret; } -- 1.9.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list