]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
tools/cgget: free cgrp_list array
authorKamalesh Babulal <kamalesh.babulal@oracle.com>
Mon, 2 Mar 2026 03:02:24 +0000 (08:32 +0530)
committerTom Hromatka <tom.hromatka@oracle.com>
Thu, 19 Mar 2026 19:07:17 +0000 (13:07 -0600)
Even after fixing per-controller leaks, ASan still reported an 8 byte
leak on exit:

    Direct leak of 8 byte(s) in 1 object(s) allocated from:
        #0 0x... in __interceptor_realloc
        #1 create_cgrp (<libcgroup-source>/src/tools/cgget.c:76)

main() freed each struct cgroup * in cgrp_list but never released the
pointer array itself, so the final realloc() stayed live. After freeing
the entries, free cgrp_list too. This fix the sanitizer warning.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
src/tools/cgget.c

index a38922acce5ba063f1857bdd241c9c63688d5dbc..55eef17bcd551e3b96bff221334cb84632e6f420 100644 (file)
@@ -862,6 +862,7 @@ int main(int argc, char *argv[])
 err:
        for (i = 0; i < cgrp_list_len; i++)
                cgroup_free(&(cgrp_list[i]));
+       free(cgrp_list);
 
        return ret;
 }