summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKen'ichi Ohmichi <oomichi@mxs.nes.nec.co.jp>2009-12-09 15:47:26 +0900
committerDhaval Giani <dhaval@linux.vnet.ibm.com>2009-12-16 14:06:39 +0530
commitbf09f042ac65dacc776279da948abd39c8e9d36b (patch)
treed228d2c19f80045a040707e1854e781ecbe17842
parentccf9ad6d879cec4ca7a9620ebe28a53b4568b5d4 (diff)
downloadlibcg-bf09f042ac65dacc776279da948abd39c8e9d36b.tar.gz
libcg-bf09f042ac65dacc776279da948abd39c8e9d36b.tar.xz
libcg-bf09f042ac65dacc776279da948abd39c8e9d36b.zip
Fix a memory leak in "cgconfig" service.
Hi, When I operated "cgconfig" service on valgrind, I found a memory leak like the following: # cat /etc/cgconfig.conf mount { cpuset = /cgroup/cpuset; cpu = /cgroup/cpu; memory = /cgroup/memory; } group user000 { cpuset { cpuset.cpus = 0; cpuset.mems = 0; } } group user000/sleep000 { cpuset { cpuset.cpus = 0; cpuset.mems = 0; } } # valgrind --tool=memcheck --leak-check=yes cgconfigparser -l /etc/cgconfig.conf ==13095== Memcheck, a memory error detector. ==13095== Copyright (C) 2002-2006, and GNU GPL'd, by Julian Seward et al. ==13095== Using LibVEX rev 1658, a library for dynamic binary translation. ==13095== Copyright (C) 2004-2006, and GNU GPL'd, by OpenWorks LLP. ==13095== Using valgrind-3.2.1, a dynamic binary instrumentation framework. ==13095== Copyright (C) 2000-2006, and GNU GPL'd, by Julian Seward et al. ==13095== For more details, rerun with: -v ==13095== ==13095== ==13095== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 4 from 1) ==13095== malloc/free: in use at exit: 43,062 bytes in 10 blocks. ==13095== malloc/free: 129 allocs, 119 frees, 85,399 bytes allocated. ==13095== For counts of detected errors, rerun with: -v ==13095== searching for pointers to 10 not-freed blocks. ==13095== checked 6,795,480 bytes. ==13095== ==13095== 28 bytes in 2 blocks are definitely lost in loss record 1 of 5 ==13095== at 0x4A0590B: realloc (vg_replace_malloc.c:306) ==13095== by 0x4C0CC24: yyparse (parse.y:117) ==13095== by 0x4C12914: cgroup_config_load_config (config.c:467) ==13095== by 0x4008A2: main (cgconfig.c:60) ==13095== ==13095== LEAK SUMMARY: ==13095== definitely lost: 28 bytes in 2 blocks. ==13095== possibly lost: 0 bytes in 0 blocks. ==13095== still reachable: 43,034 bytes in 8 blocks. ==13095== suppressed: 0 bytes in 0 blocks. ==13095== Reachable blocks (those to which a pointer was found) are not shown. ==13095== To see them, rerun with: --show-reachable=yes # This patch fixes the memory leak. Thanks Ken'ichi Ohmichi Signed-off-by: Ken'ichi Ohmichi <oomichi@mxs.nes.nec.co.jp> Acked-by: Balbir Singh <balbir@linux.vnet.ibm.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
-rw-r--r--src/parse.y1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/parse.y b/src/parse.y
index d1f8678..45de0eb 100644
--- a/src/parse.y
+++ b/src/parse.y
@@ -130,6 +130,7 @@ namevalue_conf
if ($1) {
$2 = strncat($2, ":", strlen(":"));
$$ = strncat($2, $1, strlen($1));
+ free($1);
}
free($4);
}