summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Schwab <schwab@suse.de>2022-07-25 17:12:18 +0200
committerSteven Rostedt (Google) <rostedt@goodmis.org>2022-07-31 17:03:38 -0400
commit4f753c3be52c1d930afc0fe3169baa605dbaf611 (patch)
tree8cd193d81bd146364bc1e8696748f3c13877b9b9
parentc7d8a598c5b1e21a0957f5dec2ef4139d2d1a23a (diff)
downloadlinux-stable-4f753c3be52c1d930afc0fe3169baa605dbaf611.tar.gz
linux-stable-4f753c3be52c1d930afc0fe3169baa605dbaf611.tar.bz2
linux-stable-4f753c3be52c1d930afc0fe3169baa605dbaf611.zip
rtla: Fix double free
Avoid double free by making trace_instance_destroy indempotent. When trace_instance_init fails, it calls trace_instance_destroy, but its only caller osnoise_destroy_tool calls it again. Link: https://lkml.kernel.org/r/mvmilnlkyzx.fsf_-_@suse.de Fixes: 0605bf009f18 ("rtla: Add osnoise tool") Signed-off-by: Andreas Schwab <schwab@suse.de> Acked-by: Daniel Bristot de Oliveira <bristot@kernel.org> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
-rw-r--r--tools/tracing/rtla/src/trace.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/tools/tracing/rtla/src/trace.c b/tools/tracing/rtla/src/trace.c
index 5784c9f9e570..e1ba6d9f4265 100644
--- a/tools/tracing/rtla/src/trace.c
+++ b/tools/tracing/rtla/src/trace.c
@@ -134,13 +134,18 @@ void trace_instance_destroy(struct trace_instance *trace)
if (trace->inst) {
disable_tracer(trace->inst);
destroy_instance(trace->inst);
+ trace->inst = NULL;
}
- if (trace->seq)
+ if (trace->seq) {
free(trace->seq);
+ trace->seq = NULL;
+ }
- if (trace->tep)
+ if (trace->tep) {
tep_free(trace->tep);
+ trace->tep = NULL;
+ }
}
/*