From: Arnaldo Carvalho de Melo Date: Wed, 12 Apr 2023 12:50:08 +0000 (-0300) Subject: perf tests api-io: Use zfree() to reduce chances of use after free X-Git-Tag: v6.4-rc1~1^2~86 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9ccbc21166ce149c5f7429cad22f9073d3fab0b1;p=thirdparty%2Fkernel%2Flinux.git 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 --- diff --git a/tools/perf/tests/api-io.c b/tools/perf/tests/api-io.c index 6aea84ca66734..0ba3d5ccebcfc 100644 --- a/tools/perf/tests/api-io.c +++ b/tools/perf/tests/api-io.c @@ -12,6 +12,7 @@ #include "tests.h" #include #include +#include #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); }