summaryrefslogtreecommitdiff
path: root/tools/perf/builtin-inject.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2023-04-12 15:50:08 +0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2023-04-12 15:50:08 +0300
commit79b40a1b182bcca381bb59d0219e1dd681a64981 (patch)
tree84fdb9202d752a61b7e9e910777ee3b8fe7b9da9 /tools/perf/builtin-inject.c
parentf00e589228d1d60a664dc13fef53acbde4a1d941 (diff)
downloadlinux-79b40a1b182bcca381bb59d0219e1dd681a64981.tar.xz
perf inject: 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/perf/builtin-inject.c')
-rw-r--r--tools/perf/builtin-inject.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c
index fd2b38458a5d..76723ac314b6 100644
--- a/tools/perf/builtin-inject.c
+++ b/tools/perf/builtin-inject.c
@@ -1311,10 +1311,10 @@ static void guest_session__exit(struct guest_session *gs)
if (gs->tmp_fd >= 0)
close(gs->tmp_fd);
unlink(gs->tmp_file_name);
- free(gs->tmp_file_name);
+ zfree(&gs->tmp_file_name);
}
- free(gs->vcpu);
- free(gs->perf_data_file);
+ zfree(&gs->vcpu);
+ zfree(&gs->perf_data_file);
}
static void get_tsc_conv(struct perf_tsc_conversion *tc, struct perf_record_time_conv *time_conv)