]> git.ipfire.org Git - thirdparty/libcgroup.git/commit
tools/cgexec: fix memory leak in find_scope_pid()
authorKamalesh Babulal <kamalesh.babulal@oracle.com>
Sun, 18 Jun 2023 07:10:33 +0000 (12:40 +0530)
committerTom Hromatka <tom.hromatka@oracle.com>
Wed, 21 Jun 2023 16:14:42 +0000 (10:14 -0600)
commit9a48fdc10bfec553fa63fdc6018ebf9c9c464e1d
tree6809f800171a7dc83ff32346a288a9b5a9dfb163
parent708c468260227516960225cd362961291d4bd805
tools/cgexec: fix memory leak in find_scope_pid()

Fix a memory leak, reported by the Coverity tool.

CID 321265 (#1-2 of 2): Resource leak (RESOURCE_LEAK)37. leaked_storage:
Variable pids going out of scope leaks the storage it points to.

find_scope_pid (), calls cgroup_get_procs() to get the pids of the
tasks under cgroup name, and it's up to the caller to free the allocated
pids. Fix it by calling free(pids) after every call to
cgroup_get_procs().

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