[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH] cgroup.c: avoid unconditional leaks



Here's output from "git format-patch -U19 --stdout -1",
so you see the context:

>From 47ea9beecf93a796e606b4d906424c05e7f6c9bb Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering redhat com>
Date: Thu, 4 Feb 2010 11:14:03 +0100
Subject: [PATCH] cgroup.c: avoid unconditional leaks

* src/util/cgroup.c (virCgroupCpuSetInherit) [HAVE_MNTENT_H]:
Don't leak CPU-set inheritance value strings.
---
 src/util/cgroup.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/src/util/cgroup.c b/src/util/cgroup.c
index c80cf50..e6f0270 100644
--- a/src/util/cgroup.c
+++ b/src/util/cgroup.c
@@ -416,38 +416,39 @@ static int virCgroupCpuSetInherit(virCgroupPtr parent, virCgroupPtr group)
     VIR_DEBUG("Setting up inheritance %s -> %s", parent->path, group->path);
     for (i = 0; i < ARRAY_CARDINALITY(inherit_values) ; i++) {
         char *value;

         rc = virCgroupGetValueStr(parent,
                                   VIR_CGROUP_CONTROLLER_CPUSET,
                                   inherit_values[i],
                                   &value);
         if (rc != 0) {
             VIR_ERROR("Failed to get %s %d", inherit_values[i], rc);
             break;
         }

         VIR_DEBUG("Inherit %s = %s", inherit_values[i], value);

         rc = virCgroupSetValueStr(group,
                                   VIR_CGROUP_CONTROLLER_CPUSET,
                                   inherit_values[i],
                                   value);
+        VIR_FREE(value);

         if (rc != 0) {
             VIR_ERROR("Failed to set %s %d", inherit_values[i], rc);
             break;
         }
     }

     return rc;
 }

 static int virCgroupMakeGroup(virCgroupPtr parent, virCgroupPtr group, int create)
 {
     int i;
     int rc = 0;

     VIR_DEBUG("Make group %s", group->path);
     for (i = 0 ; i < VIR_CGROUP_CONTROLLER_LAST ; i++) {
         char *path = NULL;

--
1.7.0.rc1.193.ge8618


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]