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: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 25feb605
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#include <linux/bitops.h> #include <linux/bitops.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/string.h> #include <linux/string.h>
#include <linux/zalloc.h>
#include <subcmd/parse-options.h> #include <subcmd/parse-options.h>
#include <subcmd/run-command.h> #include <subcmd/run-command.h>
...@@ -1881,7 +1882,7 @@ symbol__disassemble_bpf_image(struct symbol *sym, ...@@ -1881,7 +1882,7 @@ symbol__disassemble_bpf_image(struct symbol *sym,
if (dl) if (dl)
annotation_line__add(&dl->al, &notes->src->source); annotation_line__add(&dl->al, &notes->src->source);
free(args->line); zfree(&args->line);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment