diff options
author | Steven Rostedt (Google) <rostedt@goodmis.org> | 2023-05-30 02:56:27 -0400 |
---|---|---|
committer | Steven Rostedt (Google) <rostedt@goodmis.org> | 2023-05-30 03:02:51 -0400 |
commit | 857dd3e2a45a865037d7351b90c902cf152d2888 (patch) | |
tree | 4b1f1c03e3452f9bb26a2a4de6aa5d1aee9de050 | |
parent | 6332309276706889083bdc51b9a4d250d050482a (diff) | |
download | libtracefs-857dd3e2a45a865037d7351b90c902cf152d2888.tar.gz |
libtracefs/utest: Fix crashing of synth test when synths exist
If a synthetic event already exists when running the synthetic event test,
it does a SEGFAULT. This is because the sevents passed into
test_synth_compare() is dependent on the devents size. If there's
already a synthetic event, devents will be bigger than sevents, and the
sevents will read out of bounds. Check for devents to be the same size as
sevents before calling test_synth_compare()
Link: https://lore.kernel.org/linux-trace-devel/20230530025627.19df3714@rorschach.local.home
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
-rw-r--r-- | utest/tracefs-utest.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/utest/tracefs-utest.c b/utest/tracefs-utest.c index 0f40756..3d88d92 100644 --- a/utest/tracefs-utest.c +++ b/utest/tracefs-utest.c @@ -1047,6 +1047,12 @@ static void test_instance_synthetic(struct tracefs_instance *instance) devents = get_dynevents_check(TRACEFS_DYNEVENT_SYNTH, sevents_count); CU_TEST(devents != NULL); + if (!devents) + goto out; + CU_TEST(devents[sevents_count] == NULL); + if (devents[sevents_count]) + goto out; + test_synth_compare(sevents, devents); tracefs_dynevent_list_free(devents); @@ -1057,6 +1063,7 @@ static void test_instance_synthetic(struct tracefs_instance *instance) get_dynevents_check(TRACEFS_DYNEVENT_SYNTH, 0); + out: for (i = 0; i < sevents_count; i++) tracefs_synth_free(synth[i]); |