Skip to content

Commit

Permalink
perf inject: Use zfree() to reduce chances of use after free
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Arnaldo Carvalho de Melo committed Apr 12, 2023
1 parent f00e589 commit 79b40a1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tools/perf/builtin-inject.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 79b40a1

Please sign in to comment.