Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf tests api-io: 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>

+2 -1
+2 -1
tools/perf/tests/api-io.c
··· 12 12 #include "tests.h" 13 13 #include <api/io.h> 14 14 #include <linux/kernel.h> 15 + #include <linux/zalloc.h> 15 16 16 17 #define TEMPL "/tmp/perf-test-XXXXXX" 17 18 ··· 80 79 81 80 static void cleanup_test(char path[PATH_MAX], struct io *io) 82 81 { 83 - free(io->buf); 82 + zfree(&io->buf); 84 83 close(io->fd); 85 84 unlink(path); 86 85 }