From fe048b0dfe8990eda071ac14ad9575c0fc30eeaa Mon Sep 17 00:00:00 2001 From: Ivana Hutarova Varekova Date: Wed, 30 Oct 2013 14:17:15 +0100 Subject: [PATCH] cgroup_{reload|init}_cached_templates:memory leaks cgroup_{reload|init}_cached_templates does not free memory if no template is set. This patch fix the problem. Signed-off-by: Ivana Hutarova Varekova Acked-by: Peter Schiffer --- src/config.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/config.c b/src/config.c index ac844a7a..da2c0dd0 100644 --- a/src/config.c +++ b/src/config.c @@ -1460,7 +1460,7 @@ int cgroup_reload_cached_templates(char *pathname) } template_table_index = 0; - if (config_template_table_index != 0) { + if ((config_template_table_index != 0) || (config_table_index != 0)) { /* config template structures have to be free as well*/ cgroup_free_config(); } @@ -1515,7 +1515,16 @@ int cgroup_init_templates_cache(char *pathname) int ret = 0; int i; - if (config_template_table_index != 0) { + if (template_table) { + /* template structures have to be free */ + for (i = 0; i < template_table_index; i++) + cgroup_free_controllers(&template_table[i]); + free(template_table); + template_table = NULL; + } + template_table_index = 0; + + if ((config_template_table_index != 0) || (config_table_index != 0)) { /* config structures have to be clean */ cgroup_free_config(); } -- 2.47.2