aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Rostedt (Google) <rostedt@goodmis.org>2022-08-18 22:03:47 -0400
committerSteven Rostedt (Google) <rostedt@goodmis.org>2022-09-08 18:20:18 -0400
commit0aaa86a54a287f68a4ccafa4af772a7ed9073fde (patch)
tree6507ffb5e2c83e435b6f2a4eb5b5ef69cf303bf6
parentd2d53404ce37e576b18eebc29c1ff93c191407ba (diff)
downloadlibtracefs-0aaa86a54a287f68a4ccafa4af772a7ed9073fde.tar.gz
libtracefs: Fix use after free in tracefs_synth_alloc()
The synth new_format is set after the error condition is checked and the synth is freed (on error), causing a SIGSEV when that occurs. Link: https://lore.kernel.org/linux-trace-devel/20220819020349.747429-2-rostedt@goodmis.org Fixes: 74a6754b9e67b ("libtracefs: Check README to know if we should do old onmatch format") Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
-rw-r--r--src/tracefs-hist.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/tracefs-hist.c b/src/tracefs-hist.c
index 2f12cc4..6f7d657 100644
--- a/src/tracefs-hist.c
+++ b/src/tracefs-hist.c
@@ -1091,9 +1091,8 @@ struct tracefs_synth *tracefs_synth_alloc(struct tep_handle *tep,
if (!synth->name || !synth->start_keys || !synth->end_keys || ret) {
tracefs_synth_free(synth);
synth = NULL;
- }
-
- synth->new_format = has_new_format();
+ } else
+ synth->new_format = has_new_format();
return synth;
}