Fix version string memory leak

Signed-off-by: Bolehu <heyaohua@xfusion.com>
This commit is contained in:
Bolehu 2023-01-06 04:03:28 +08:00
parent 1003bc9148
commit ff1c65752d
2 changed files with 44 additions and 1 deletions

View File

@ -0,0 +1,39 @@
From c5d548379b25705c2061b8c010f78fd242212f65 Mon Sep 17 00:00:00 2001
From: "Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com>
Date: Tue, 14 Sep 2021 16:12:14 +0300
Subject: [PATCH] trace-cmd library: Fix version string memory leak
The version string is allocated when a VERSION option is processed, but
is never freed. Free it on input handler close.
Link: https://lore.kernel.org/linux-trace-devel/20210914131232.3964615-4-tz.stoyanov@gmail.com
Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
lib/trace-cmd/trace-input.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/lib/trace-cmd/trace-input.c b/lib/trace-cmd/trace-input.c
index 0dbcdbdc..9253bc37 100644
--- a/lib/trace-cmd/trace-input.c
+++ b/lib/trace-cmd/trace-input.c
@@ -3518,6 +3518,7 @@ void tracecmd_close(struct tracecmd_input *handle)
free(handle->cpu_data);
free(handle->uname);
free(handle->trace_clock);
+ free(handle->version);
close(handle->fd);
tracecmd_free_hooks(handle->hooks);
@@ -3959,6 +3960,7 @@ tracecmd_buffer_instance_handle(struct tracecmd_input *handle, int indx)
new_handle->cpu_data = NULL;
new_handle->nr_buffers = 0;
new_handle->buffers = NULL;
+ new_handle->version = NULL;
new_handle->ref = 1;
if (handle->trace_clock) {
new_handle->trace_clock = strdup(handle->trace_clock);
--
2.33.0

View File

@ -1,6 +1,6 @@
Name: trace-cmd
Version: 2.9.2
Release: 4
Release: 5
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
@ -8,6 +8,7 @@ Source0: https://git.kernel.org/pub/scm/linux/kernel/git/rostedt/tra
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
BuildRequires: gcc xmlto asciidoc mlocate libxml2-devel chrpath
BuildRequires: gtk2-devel glib2-devel desktop-file-utils libtraceevent-devel
@ -67,6 +68,9 @@ echo "%{_bindir}/%{name}" > $RPM_BUILD_ROOT/etc/ld.so.conf.d/%{name}-%{_arch}.co
%{_mandir}/man5/*
%changelog
* Fri Jan 06 2023 Bolehu <heyaohua@xfusion.com> - 2.9.2-5
- trace-cmd library: Fix version string memory leak
* Fri Jan 06 2023 Bolehu <heyaohua@xfusion.com> - 2.9.2-4
- trace-cmd report: Fix typos in error messages