diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2023-04-12 09:50:08 -0300 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2023-04-12 10:14:58 -0300 |
commit | 9ccbc21166ce149c5f7429cad22f9073d3fab0b1 (patch) | |
tree | a63bfc3769a86ba37bfde7875cfb1f23d73f8308 /tools | |
parent | 97d0dd1e283a9a11ede495928c9c2a148b47cef4 (diff) | |
download | linux-stable-9ccbc21166ce149c5f7429cad22f9073d3fab0b1.tar.gz linux-stable-9ccbc21166ce149c5f7429cad22f9073d3fab0b1.tar.bz2 linux-stable-9ccbc21166ce149c5f7429cad22f9073d3fab0b1.zip |
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>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/tests/api-io.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/tools/perf/tests/api-io.c b/tools/perf/tests/api-io.c index 6aea84ca6673..0ba3d5ccebcf 100644 --- a/tools/perf/tests/api-io.c +++ b/tools/perf/tests/api-io.c @@ -12,6 +12,7 @@ #include "tests.h" #include <api/io.h> #include <linux/kernel.h> +#include <linux/zalloc.h> #define TEMPL "/tmp/perf-test-XXXXXX" @@ -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) { - free(io->buf); + zfree(&io->buf); close(io->fd); unlink(path); } |