[PATCH 34/38] trace-cmd mem: prevent a memory leak in trace_mem()

"Jerome Marchand" <[email protected]>
Newsgroups org.kernel.vger.linux-trace-devel
Message-ID <[email protected]>
Close the tracecmd handle in the error path.

Fixes a RESOURCE_LEAK error (CWE-772)

Signed-off-by: Jerome Marchand <[email protected]>
---
 tracecmd/trace-mem.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tracecmd/trace-mem.c b/tracecmd/trace-mem.c
index 3e1ac9f3..6182b096 100644
--- a/tracecmd/trace-mem.c
+++ b/tracecmd/trace-mem.c
@@ -555,9 +555,10 @@ void trace_mem(int argc, char **argv)
 
 	ret = tracecmd_read_headers(handle, 0);
 	if (ret)
-		return;
+		goto out;
 
 	do_trace_mem(handle);
 
+out:
 	tracecmd_close(handle);
 }
-- 
2.44.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.