[libvirt] [PATCH 1/2] virCgroupNewPartition: Don't leak @newpath

The @newpath variable is allocated in virCgroupSetPartitionSuffix(). But it's newer freed. --- src/util/vircgroup.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index ae71859..e0b25ed 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -1249,7 +1249,7 @@ int virCgroupNewPartition(const char *path, int rc; char *parentPath = NULL; virCgroupPtr parent = NULL; - char *newpath; + char *newpath = NULL; VIR_DEBUG("path=%s create=%d controllers=%x", path, create, controllers); @@ -1295,6 +1295,7 @@ cleanup: virCgroupFree(group); virCgroupFree(&parent); VIR_FREE(parentPath); + VIR_FREE(newpath); return rc; } #else -- 1.8.1.5

When removing a TAP device, the associated bandwidth settings are removed. Currently, the /sbin/tc is used for that. It is spawned several times. Moreover, we use the same @cmd variable to construct the command and its arguments. That means we need to virCommandFree(cmd); prior to each virCommandNew(TC); which wasn't done. --- src/util/virnetdevbandwidth.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/util/virnetdevbandwidth.c b/src/util/virnetdevbandwidth.c index ccc1449..74e6c8c 100644 --- a/src/util/virnetdevbandwidth.c +++ b/src/util/virnetdevbandwidth.c @@ -519,6 +519,7 @@ virNetDevBandwidthUnplug(const char *brname, if (virCommandRun(cmd, &cmd_ret) < 0) goto cleanup; + virCommandFree(cmd); cmd = virCommandNew(TC); virCommandAddArgList(cmd, "class", "del", "dev", brname, "classid", class_id, NULL); -- 1.8.1.5

On 07/03/2013 09:47 AM, Michal Privoznik wrote:
When removing a TAP device, the associated bandwidth settings are removed. Currently, the /sbin/tc is used for that. It is spawned several times. Moreover, we use the same @cmd variable to construct the command and its arguments. That means we need to virCommandFree(cmd); prior to each virCommandNew(TC); which wasn't done. --- src/util/virnetdevbandwidth.c | 1 + 1 file changed, 1 insertion(+)
ACK Jan

On 07/03/2013 09:50 AM, Ján Tomko wrote:
On 07/03/2013 09:47 AM, Michal Privoznik wrote:
The @newpath variable is allocated in virCgroupSetPartitionSuffix(). But it's newer freed. --- src/util/vircgroup.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
ACK
Jan
s/newer/never/ in the commit message.
participants (2)
-
Ján Tomko
-
Michal Privoznik