]> git.ipfire.org Git - thirdparty/libcgroup.git/commit
tools/cgget: fix resource leak in get_cv_value()
authorKamalesh Babulal <kamalesh.babulal@oracle.com>
Wed, 27 Jul 2022 18:49:57 +0000 (12:49 -0600)
committerTom Hromatka <tom.hromatka@oracle.com>
Wed, 27 Jul 2022 18:50:00 +0000 (12:50 -0600)
commite5031f8b5472a41c53f517188dff7adfa1b04f2c
treea61246acae3e38a8f517c783aaeb15dbc97f2741
parent21c50cb860304ad99af920e80e48df941ecf7d75
tools/cgget: fix resource leak in get_cv_value()

Fix a resource leak, reported by the Coverity tool:

CID 258291 (#1 of 1): Resource leak (RESOURCE_LEAK)8. leaked_storage:
Variable handle going out of scope leaks the storage it points to.

In get_cv_value(), currently, we goto end label, on the failure of
strdup() before closing the handle, leaking the resource. Fix it by
removing the goto, that allows the code flow to close the handle and
execute the code under the end label.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit d8bf0b38a75ed06520d05d130c0c92234df8665f)
src/tools/cgget.c