diff mbox series

[21/38] trace-cmd record: prevent memory leak in clear_func_filter()

Message ID 20240605134054.2626953-22-jmarchan@redhat.com (mailing list archive)
State Accepted
Commit 8e8b172d46b160f92e0e5e8b0eb7687b4376971f
Headers show
Series trace-cmd: fix misc issues found by static analysis | expand

Commit Message

Jerome Marchand June 5, 2024, 1:40 p.m. UTC
Free buf at the end of the function.

Fixes a RESOURCE_LEAK error (CWE-772)

Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
---
 tracecmd/trace-record.c | 1 +
 1 file changed, 1 insertion(+)
diff mbox series

Patch

diff --git a/tracecmd/trace-record.c b/tracecmd/trace-record.c
index a9e5e64d..2223d5bb 100644
--- a/tracecmd/trace-record.c
+++ b/tracecmd/trace-record.c
@@ -2509,6 +2509,7 @@  static void clear_func_filter(const char *file)
 		filter[len+1] = '\0';
 		write_file(file, filter);
 	}
+	free(buf);
 }
 
 static void update_reset_triggers(void)