Skip to content

Commit

Permalink
rtla: Fix double free
Browse files Browse the repository at this point in the history
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: 0605bf0 ("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>
  • Loading branch information
Andreas Schwab authored and Steven Rostedt (Google) committed Jul 31, 2022
1 parent c7d8a59 commit 4f753c3
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions tools/tracing/rtla/src/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

/*
Expand Down

0 comments on commit 4f753c3

Please sign in to comment.