Skip to content

Commit 4f753c3

Browse files
andreas-schwabrostedt
authored andcommitted
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/[email protected] Fixes: 0605bf0 ("rtla: Add osnoise tool") Signed-off-by: Andreas Schwab <[email protected]> Acked-by: Daniel Bristot de Oliveira <[email protected]> Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent c7d8a59 commit 4f753c3

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

tools/tracing/rtla/src/trace.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,18 @@ void trace_instance_destroy(struct trace_instance *trace)
134134
if (trace->inst) {
135135
disable_tracer(trace->inst);
136136
destroy_instance(trace->inst);
137+
trace->inst = NULL;
137138
}
138139

139-
if (trace->seq)
140+
if (trace->seq) {
140141
free(trace->seq);
142+
trace->seq = NULL;
143+
}
141144

142-
if (trace->tep)
145+
if (trace->tep) {
143146
tep_free(trace->tep);
147+
trace->tep = NULL;
148+
}
144149
}
145150

146151
/*

0 commit comments

Comments
 (0)