diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2023-04-12 14:50:08 +0200 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2023-04-12 15:12:55 +0200 |
commit | e413f9f13f6a8a591af0ac39ef50af02b42a0df8 (patch) | |
tree | d4cfaaaa8487f91f30e3572a2e6164bdf0899074 | |
parent | perf evlist: Use zfree() to reduce chances of use after free (diff) | |
download | linux-e413f9f13f6a8a591af0ac39ef50af02b42a0df8.tar.xz linux-e413f9f13f6a8a591af0ac39ef50af02b42a0df8.zip |
perf genelf: 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>
-rw-r--r-- | tools/perf/util/genelf_debug.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/tools/perf/util/genelf_debug.c b/tools/perf/util/genelf_debug.c index 8786c366566e..aa5dcc56b2ac 100644 --- a/tools/perf/util/genelf_debug.c +++ b/tools/perf/util/genelf_debug.c @@ -11,6 +11,7 @@ * @author Philippe Elie */ #include <linux/compiler.h> +#include <linux/zalloc.h> #include <sys/types.h> #include <stdio.h> #include <getopt.h> @@ -90,7 +91,7 @@ buffer_ext_init(struct buffer_ext *be) static void buffer_ext_exit(struct buffer_ext *be) { - free(be->data); + zfree(&be->data); } static inline size_t |