perf annotate: Use zfree() to avoid possibly accessing dangling pointers

When freeing a->b it is good practice to set a->b to NULL using
zfree(&a->b) so that when we have a bug where a reference to a freed 'a'
pointer is kept somewhere, we can more quickly cause a segfault if some
code tries to use a->b.

This is mostly done but some new cases were introduced recently, convert
them to zfree().

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/lkml/ZjmbHHrjIm5YRIBv@x1
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Arnaldo Carvalho de Melo
2024-05-07 00:04:06 -03:00
parent 37862d6fdc
commit 69fb6eab19
3 changed files with 13 additions and 11 deletions

View File

@@ -2618,13 +2618,13 @@ static void delete_basic_blocks(struct basic_block_data *bb_data)
list_for_each_entry_safe(link, tmp, &bb_data->queue, node) {
list_del(&link->node);
free(link->bb);
zfree(&link->bb);
free(link);
}
list_for_each_entry_safe(link, tmp, &bb_data->visited, node) {
list_del(&link->node);
free(link->bb);
zfree(&link->bb);
free(link);
}
}