From c77ceb2eb03eefd92e6b84a509ecec1db8d97858 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Wed, 12 Apr 2023 09:50:08 -0300 Subject: perf annotate: 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. Also include the missing linux/zalloc.h header directive. Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/annotate.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tools/perf/util/annotate.c') diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 55f2e3a7577e..e2693a1c28d5 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -38,6 +38,7 @@ #include #include #include +#include #include #include @@ -1881,7 +1882,7 @@ symbol__disassemble_bpf_image(struct symbol *sym, if (dl) annotation_line__add(&dl->al, ¬es->src->source); - free(args->line); + zfree(&args->line); return 0; } -- cgit