Commit 313b4c1c authored by Arnaldo Carvalho de Melo's avatar Arnaldo Carvalho de Melo
Browse files

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
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -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);
		}
	}
}