]> git.ipfire.org Git - thirdparty/libcgroup.git/commit
tools/cgxset: Fix potential memory leak in converted_src_cgroup
authorTom Hromatka <tom.hromatka@oracle.com>
Wed, 22 Feb 2023 21:09:07 +0000 (14:09 -0700)
committerTom Hromatka <tom.hromatka@oracle.com>
Fri, 24 Feb 2023 19:47:13 +0000 (12:47 -0700)
commitf1579cec2734c767d24f69944e1e5f07e1c1e3af
treeaeea193e1854379e649c0ff631a9c6bbbe865128
parent4bec8844d71e3c7428dddcff29c7006dc378a5ec
tools/cgxset: Fix potential memory leak in converted_src_cgroup

There's a brief window where converted_src_cgroup is allocated but
hasn't been assigned to the *cgroup pointer.  If a failure occurs in
this window, then converted_src_cgroup must be freed before doing the
goto to the error path.

Also, simplify the error-handling logic in cgxset::main() by having all
errors goto "err".

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