mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-29 05:44:11 +00:00
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>
This commit is contained in:
parent
9997d5dd17
commit
190de75481
1 changed files with 7 additions and 7 deletions
|
@ -165,8 +165,8 @@ static void *c2c_he_zalloc(size_t size)
|
||||||
return &c2c_he->he;
|
return &c2c_he->he;
|
||||||
|
|
||||||
out_free:
|
out_free:
|
||||||
free(c2c_he->nodeset);
|
zfree(&c2c_he->nodeset);
|
||||||
free(c2c_he->cpuset);
|
zfree(&c2c_he->cpuset);
|
||||||
free(c2c_he);
|
free(c2c_he);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -178,13 +178,13 @@ static void c2c_he_free(void *he)
|
||||||
c2c_he = container_of(he, struct c2c_hist_entry, he);
|
c2c_he = container_of(he, struct c2c_hist_entry, he);
|
||||||
if (c2c_he->hists) {
|
if (c2c_he->hists) {
|
||||||
hists__delete_entries(&c2c_he->hists->hists);
|
hists__delete_entries(&c2c_he->hists->hists);
|
||||||
free(c2c_he->hists);
|
zfree(&c2c_he->hists);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(c2c_he->cpuset);
|
zfree(&c2c_he->cpuset);
|
||||||
free(c2c_he->nodeset);
|
zfree(&c2c_he->nodeset);
|
||||||
free(c2c_he->nodestr);
|
zfree(&c2c_he->nodestr);
|
||||||
free(c2c_he->node_stats);
|
zfree(&c2c_he->node_stats);
|
||||||
free(c2c_he);
|
free(c2c_he);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue