]> xenbits.xensource.com Git - people/pauldu/linux.git/commitdiff
perf annotate: Use zfree() to reduce chances of use after free
authorArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 12 Apr 2023 12:50:08 +0000 (09:50 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 12 Apr 2023 13:08:30 +0000 (10:08 -0300)
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>
tools/perf/util/annotate.c

index 55f2e3a7577e372f018a64823d080468e4e2d632..e2693a1c28d5989fdda81500e6dfa4686fc7ad8e 100644 (file)
@@ -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;
 }