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: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 97d0dd1e
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "tests.h" #include "tests.h"
#include <api/io.h> #include <api/io.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/zalloc.h>
#define TEMPL "/tmp/perf-test-XXXXXX" #define TEMPL "/tmp/perf-test-XXXXXX"
...@@ -79,7 +80,7 @@ static int setup_test(char path[PATH_MAX], const char *contents, ...@@ -79,7 +80,7 @@ static int setup_test(char path[PATH_MAX], const char *contents,
static void cleanup_test(char path[PATH_MAX], struct io *io) static void cleanup_test(char path[PATH_MAX], struct io *io)
{ {
free(io->buf); zfree(&io->buf);
close(io->fd); close(io->fd);
unlink(path); unlink(path);
} }
......
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