summaryrefslogtreecommitdiff
path: root/tools/perf/builtin-c2c.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2023-04-12 15:50:08 +0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2023-04-12 15:55:10 +0300
commit190de75481439205f3a9362bd0511fd48ad1a718 (patch)
tree7c7e7e11d6e507fc66f6a145cc4b815b2948fefd /tools/perf/builtin-c2c.c
parent9997d5dd177c52017fa0541bf236a4232c8148e6 (diff)
downloadlinux-190de75481439205f3a9362bd0511fd48ad1a718.tar.xz
perf c2c: 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/builtin-c2c.c')
-rw-r--r--tools/perf/builtin-c2c.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c
index 6c12f0865860..08455e26b606 100644
--- a/tools/perf/builtin-c2c.c
+++ b/tools/perf/builtin-c2c.c
@@ -165,8 +165,8 @@ static void *c2c_he_zalloc(size_t size)
return &c2c_he->he;
out_free:
- free(c2c_he->nodeset);
- free(c2c_he->cpuset);
+ zfree(&c2c_he->nodeset);
+ zfree(&c2c_he->cpuset);
free(c2c_he);
return NULL;
}
@@ -178,13 +178,13 @@ static void c2c_he_free(void *he)
c2c_he = container_of(he, struct c2c_hist_entry, he);
if (c2c_he->hists) {
hists__delete_entries(&c2c_he->hists->hists);
- free(c2c_he->hists);
+ zfree(&c2c_he->hists);
}
- free(c2c_he->cpuset);
- free(c2c_he->nodeset);
- free(c2c_he->nodestr);
- free(c2c_he->node_stats);
+ zfree(&c2c_he->cpuset);
+ zfree(&c2c_he->nodeset);
+ zfree(&c2c_he->nodestr);
+ zfree(&c2c_he->node_stats);
free(c2c_he);
}