From: Arnaldo Carvalho de Melo Date: Wed, 12 Apr 2023 12:50:08 +0000 (-0300) Subject: perf annotate: Use zfree() to reduce chances of use after free X-Git-Tag: v6.4-rc1~1^2~90 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c77ceb2eb03eefd92e6b84a509ecec1db8d97858;p=thirdparty%2Fkernel%2Flinux.git 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 --- diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 55f2e3a7577e3..e2693a1c28d59 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; }