From: Kamalesh Babulal Date: Wed, 27 Jul 2022 19:01:31 +0000 (-0600) Subject: tools/cgxget: fix the resource leak in convert_cgroup() X-Git-Tag: v3.0~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=66799b867c7ace0affa61fba70fb0fab42725499;p=thirdparty%2Flibcgroup.git tools/cgxget: fix the resource leak in convert_cgroup() Fix a resource leak warning reported by the Coverity tool: CID 258272 (#1-2 of 2): Resource leak (RESOURCE_LEAK). leaked_storage: Variable cg_converted_list going out of scope leaks the storage it points to. while free'ing() the cg_converted_list() via cgroup_free(), wrong array index variable was passed, causing the resource leak. Fix it by passing the right index variable. Signed-off-by: Kamalesh Babulal Signed-off-by: Tom Hromatka --- diff --git a/src/tools/cgxget.c b/src/tools/cgxget.c index 0a8cbc56..96fe79b4 100644 --- a/src/tools/cgxget.c +++ b/src/tools/cgxget.c @@ -769,7 +769,7 @@ out: if (ret != 0 && ret != ECGNOVERSIONCONVERT) { /* The conversion failed */ for (j = 0; j < i; j++) - cgroup_free(&(cg_converted_list[i])); + cgroup_free(&(cg_converted_list[j])); } else { /* * The conversion succeeded or was unmappable.