diff --git a/backport-trace-cmd-library-Fixed-a-memory-leak-on-input-handl.patch b/backport-trace-cmd-library-Fixed-a-memory-leak-on-input-handl.patch new file mode 100644 index 0000000000000000000000000000000000000000..e2465a71607df9b56fc99e0c6279b1315a0a42bd --- /dev/null +++ b/backport-trace-cmd-library-Fixed-a-memory-leak-on-input-handl.patch @@ -0,0 +1,43 @@ +From 402be29ae6fa1e29c963c71be2713687a4a71686 Mon Sep 17 00:00:00 2001 +From: "Tzvetomir Stoyanov (VMware)" +Date: Tue, 14 Sep 2021 16:12:15 +0300 +Subject: [PATCH] trace-cmd library: Fixed a memory leak on input handler close + +When an input handler to a trace file is closed with tracecmd_close(), +the list with buffers is not freed. This leads to a memory leak. Added +logic to free that list. + +Link: https://lore.kernel.org/linux-trace-devel/20210914131232.3964615-5-tz.stoyanov@gmail.com + +Signed-off-by: Tzvetomir Stoyanov (VMware) +Signed-off-by: Steven Rostedt (VMware) +--- + lib/trace-cmd/trace-input.c | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/lib/trace-cmd/trace-input.c b/lib/trace-cmd/trace-input.c +index 9253bc37..ffe87e8a 100644 +--- a/lib/trace-cmd/trace-input.c ++++ b/lib/trace-cmd/trace-input.c +@@ -3484,6 +3484,7 @@ void tracecmd_ref(struct tracecmd_input *handle) + void tracecmd_close(struct tracecmd_input *handle) + { + int cpu; ++ int i; + + if (!handle) + return; +@@ -3521,6 +3522,10 @@ void tracecmd_close(struct tracecmd_input *handle) + free(handle->version); + close(handle->fd); + ++ for (i = 0; i < handle->nr_buffers; i++) ++ free(handle->buffers[i].name); ++ free(handle->buffers); ++ + tracecmd_free_hooks(handle->hooks); + handle->hooks = NULL; + +-- +2.33.0 + diff --git a/trace-cmd.spec b/trace-cmd.spec index 858067c09e8a4d054443f640f3fcb74f8c65f3e9..8ad71d1dc39aa3f22e1e8a47adbe9be73d2c0d59 100644 --- a/trace-cmd.spec +++ b/trace-cmd.spec @@ -1,6 +1,6 @@ Name: trace-cmd Version: 2.9.2 -Release: 5 +Release: 6 Summary: A front-end for Ftrace License: GPLv2 and LGPLv2 URL: http://git.kernel.org/?p=linux/kernel/git/rostedt/trace-cmd.git;a=summary @@ -9,6 +9,7 @@ Source1: kernelshark.desktop Patch0001: backport-trace-cmd-report-Fix-typos-in-error-messages.patch Patch0002: backport-trace-cmd-library-Fix-version-string-memory-leak.patch +Patch0003: backport-trace-cmd-library-Fixed-a-memory-leak-on-input-handl.patch BuildRequires: gcc xmlto asciidoc mlocate libxml2-devel chrpath BuildRequires: gtk2-devel glib2-devel desktop-file-utils libtraceevent-devel @@ -68,6 +69,9 @@ echo "%{_bindir}/%{name}" > $RPM_BUILD_ROOT/etc/ld.so.conf.d/%{name}-%{_arch}.co %{_mandir}/man5/* %changelog +* Fri Jan 06 2023 Bolehu - 2.9.2-6 +- trace-cmd library: Fixed a memory leak on input handler close + * Fri Jan 06 2023 Bolehu - 2.9.2-5 - trace-cmd library: Fix version string memory leak