summaryrefslogtreecommitdiffstats
path: root/tools/perf/bench/inject-buildid.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2023-04-12 14:50:08 +0200
committerArnaldo Carvalho de Melo <acme@redhat.com>2023-04-12 15:14:01 +0200
commit97d0dd1e283a9a11ede495928c9c2a148b47cef4 (patch)
treef53a6a9f2e96889bbffbda62df48f8e5b5899d64 /tools/perf/bench/inject-buildid.c
parentperf genelf: Use zfree() to reduce chances of use after free (diff)
downloadlinux-97d0dd1e283a9a11ede495928c9c2a148b47cef4.tar.xz
linux-97d0dd1e283a9a11ede495928c9c2a148b47cef4.zip
perf bench inject-buildid: 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. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/bench/inject-buildid.c')
-rw-r--r--tools/perf/bench/inject-buildid.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/tools/perf/bench/inject-buildid.c b/tools/perf/bench/inject-buildid.c
index 4561bda0ce6a..49331743c743 100644
--- a/tools/perf/bench/inject-buildid.c
+++ b/tools/perf/bench/inject-buildid.c
@@ -12,6 +12,7 @@
#include <linux/time64.h>
#include <linux/list.h>
#include <linux/err.h>
+#include <linux/zalloc.h>
#include <internal/lib.h>
#include <subcmd/parse-options.h>
@@ -122,7 +123,7 @@ static void release_dso(void)
for (i = 0; i < nr_dsos; i++) {
struct bench_dso *dso = &dsos[i];
- free(dso->name);
+ zfree(&dso->name);
}
free(dsos);
}