37 lines
1000 B
Diff
37 lines
1000 B
Diff
|
From b0e1a9c5c099282d30fee8f6aa89bd12ce5e8a73 Mon Sep 17 00:00:00 2001
|
||
|
From: Jerome Marchand <jmarchan@redhat.com>
|
||
|
Date: Tue, 29 Oct 2024 09:01:16 +0100
|
||
|
Subject: [PATCH 7/8] trace-cmd mem: Prevent a memory leak in trace_mem()
|
||
|
|
||
|
Close the tracecmd handle in the error path.
|
||
|
|
||
|
Fixes a RESOURCE_LEAK error (CWE-772)
|
||
|
|
||
|
Link: https://lore.kernel.org/20241029080117.625177-8-jmarchan@redhat.com
|
||
|
Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
|
||
|
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
|
||
|
---
|
||
|
tracecmd/trace-mem.c | 6 ++----
|
||
|
1 file changed, 2 insertions(+), 4 deletions(-)
|
||
|
|
||
|
diff --git a/tracecmd/trace-mem.c b/tracecmd/trace-mem.c
|
||
|
index 3e1ac9f3..b8babbbc 100644
|
||
|
--- a/tracecmd/trace-mem.c
|
||
|
+++ b/tracecmd/trace-mem.c
|
||
|
@@ -554,10 +554,8 @@ void trace_mem(int argc, char **argv)
|
||
|
die("can't open %s\n", input_file);
|
||
|
|
||
|
ret = tracecmd_read_headers(handle, 0);
|
||
|
- if (ret)
|
||
|
- return;
|
||
|
-
|
||
|
- do_trace_mem(handle);
|
||
|
+ if (!ret)
|
||
|
+ do_trace_mem(handle);
|
||
|
|
||
|
tracecmd_close(handle);
|
||
|
}
|
||
|
--
|
||
|
2.47.0
|
||
|
|