summaryrefslogtreecommitdiff
path: root/tools/perf/util/annotate.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2023-04-12 09:50:08 -0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2023-04-12 10:08:30 -0300
commitc77ceb2eb03eefd92e6b84a509ecec1db8d97858 (patch)
tree1ab8316a7b1698b0478942bfb94fe2f17c419d0f /tools/perf/util/annotate.c
parent25feb605fe3b2674142d084379e0737a99945aba (diff)
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 <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/annotate.c')
-rw-r--r--tools/perf/util/annotate.c3
1 files changed, 2 insertions, 1 deletions
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 <linux/bitops.h>
#include <linux/kernel.h>
#include <linux/string.h>
+#include <linux/zalloc.h>
#include <subcmd/parse-options.h>
#include <subcmd/run-command.h>
@@ -1881,7 +1882,7 @@ symbol__disassemble_bpf_image(struct symbol *sym,
if (dl)
annotation_line__add(&dl->al, &notes->src->source);
- free(args->line);
+ zfree(&args->line);
return 0;
}