diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2023-04-12 09:50:08 -0300 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2023-04-12 09:59:19 -0300 |
commit | 313b4c1ccdb273f6733e8c44948f8c7141f592a4 (patch) | |
tree | b74f330fa994b04e30d1b6e474e77cb5c7aeb7eb /tools/perf/arch/x86 | |
parent | d729163d0641d8b4c50fdca1b2b9d5d24d9d376d (diff) | |
download | linux-313b4c1ccdb273f6733e8c44948f8c7141f592a4.tar.gz linux-313b4c1ccdb273f6733e8c44948f8c7141f592a4.tar.bz2 linux-313b4c1ccdb273f6733e8c44948f8c7141f592a4.zip |
perf x86 iostat: 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/arch/x86')
-rw-r--r-- | tools/perf/arch/x86/util/iostat.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/tools/perf/arch/x86/util/iostat.c b/tools/perf/arch/x86/util/iostat.c index 7eb0a7b00b95..df7b5dfcc26a 100644 --- a/tools/perf/arch/x86/util/iostat.c +++ b/tools/perf/arch/x86/util/iostat.c @@ -10,6 +10,7 @@ #include <api/fs/fs.h> #include <linux/kernel.h> #include <linux/err.h> +#include <linux/zalloc.h> #include <limits.h> #include <stdio.h> #include <string.h> @@ -100,8 +101,8 @@ static void iio_root_ports_list_free(struct iio_root_ports_list *list) if (list) { for (idx = 0; idx < list->nr_entries; idx++) - free(list->rps[idx]); - free(list->rps); + zfree(&list->rps[idx]); + zfree(&list->rps); free(list); } } @@ -390,7 +391,7 @@ void iostat_release(struct evlist *evlist) evlist__for_each_entry(evlist, evsel) { if (rp != evsel->priv) { rp = evsel->priv; - free(evsel->priv); + zfree(&evsel->priv); } } } |