From: Dhaval Giani Date: Tue, 16 Nov 2010 13:29:51 +0000 (+0100) Subject: v2 [patch 6/6] api: Fix cgroup_walk_tree_begin memory leak X-Git-Tag: v0.37~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=db183fafc710a0272ba6fa89a6d3188e5ca9a13a;p=thirdparty%2Flibcgroup.git v2 [patch 6/6] api: Fix cgroup_walk_tree_begin memory leak As pointed out by Steve Grubb at http://article.gmane.org/gmane.comp.lib.libcg.devel/2485 we leak entry in cgroup_walk_tree_begin When we fail fts_read, we need to ensure that entry is freed on return. Do so. Reported-by: Steve Grubb Signed-off-by: Dhaval Giani Acked-By: Jan Safranek --- diff --git a/src/api.c b/src/api.c index e34c928e..a51230bd 100644 --- a/src/api.c +++ b/src/api.c @@ -2839,6 +2839,7 @@ int cgroup_walk_tree_begin(const char *controller, const char *base_path, ent = fts_read(entry->fts); if (!ent) { cgroup_dbg("fts_read failed\n"); + free(entry); return ECGINVAL; } if (!*base_level && depth)