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: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent d729163d
......@@ -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);
}
}
}
......
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