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>
This commit is contained in:
Родитель
d729163d06
Коммит
313b4c1ccd
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче