diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2023-04-12 15:50:08 +0300 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2023-04-12 15:55:44 +0300 |
commit | b20c63084eb2c591006109aefbdeb3cad7a57d23 (patch) | |
tree | e173665b927b8b8352606d8cf17c98a1919c0300 /tools/perf/builtin-list.c | |
parent | 190de75481439205f3a9362bd0511fd48ad1a718 (diff) | |
download | linux-b20c63084eb2c591006109aefbdeb3cad7a57d23.tar.xz |
perf list: Use zfree() to reduce chances of use after free
Do defensive programming by using zfree() to initialize freed pointers
to NULL, so that eventual use after free result in a NULL pointer deref
instead of more subtle behaviour.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/builtin-list.c')
-rw-r--r-- | tools/perf/builtin-list.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/tools/perf/builtin-list.c b/tools/perf/builtin-list.c index 29f09cefed88..1f5dbd5f0ba4 100644 --- a/tools/perf/builtin-list.c +++ b/tools/perf/builtin-list.c @@ -127,7 +127,7 @@ static void default_print_event(void *ps, const char *pmu_name, const char *topi if (strcmp(print_state->last_topic, topic ?: "")) { if (topic) printf("\n%s:\n", topic); - free(print_state->last_topic); + zfree(&print_state->last_topic); print_state->last_topic = strdup(topic ?: ""); } @@ -197,7 +197,7 @@ static void default_print_metric(void *ps, else printf("%s\n", group); } - free(print_state->last_metricgroups); + zfree(&print_state->last_metricgroups); print_state->last_metricgroups = strdup(group ?: ""); } if (!print_state->metrics) |