mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-11 03:24:58 -06:00
accel/tcg: Unmap perf_marker
Coverity complains that perf_marker is never unmapped.
Fix by unmapping it in perf_exit().
Fixes: Coverity CID 1507929
Fixes: 5584e2dbe8
("tcg: add perfmap and jitdump")
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Message-Id: <20230605114134.1169974-1-iii@linux.ibm.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
parent
514fea9eaf
commit
e7cd7a3916
1 changed files with 9 additions and 2 deletions
|
@ -111,6 +111,8 @@ static void write_perfmap_entry(const void *start, size_t insn,
|
||||||
}
|
}
|
||||||
|
|
||||||
static FILE *jitdump;
|
static FILE *jitdump;
|
||||||
|
static size_t perf_marker_size;
|
||||||
|
static void *perf_marker = MAP_FAILED;
|
||||||
|
|
||||||
#define JITHEADER_MAGIC 0x4A695444
|
#define JITHEADER_MAGIC 0x4A695444
|
||||||
#define JITHEADER_VERSION 1
|
#define JITHEADER_VERSION 1
|
||||||
|
@ -190,7 +192,6 @@ void perf_enable_jitdump(void)
|
||||||
{
|
{
|
||||||
struct jitheader header;
|
struct jitheader header;
|
||||||
char jitdump_file[32];
|
char jitdump_file[32];
|
||||||
void *perf_marker;
|
|
||||||
|
|
||||||
if (!use_rt_clock) {
|
if (!use_rt_clock) {
|
||||||
warn_report("CLOCK_MONOTONIC is not available, proceeding without jitdump");
|
warn_report("CLOCK_MONOTONIC is not available, proceeding without jitdump");
|
||||||
|
@ -210,7 +211,8 @@ void perf_enable_jitdump(void)
|
||||||
* PERF_RECORD_MMAP or PERF_RECORD_MMAP2 event is of the form jit-%d.dump
|
* PERF_RECORD_MMAP or PERF_RECORD_MMAP2 event is of the form jit-%d.dump
|
||||||
* and will process it as a jitdump file.
|
* and will process it as a jitdump file.
|
||||||
*/
|
*/
|
||||||
perf_marker = mmap(NULL, qemu_real_host_page_size(), PROT_READ | PROT_EXEC,
|
perf_marker_size = qemu_real_host_page_size();
|
||||||
|
perf_marker = mmap(NULL, perf_marker_size, PROT_READ | PROT_EXEC,
|
||||||
MAP_PRIVATE, fileno(jitdump), 0);
|
MAP_PRIVATE, fileno(jitdump), 0);
|
||||||
if (perf_marker == MAP_FAILED) {
|
if (perf_marker == MAP_FAILED) {
|
||||||
warn_report("Could not map %s: %s, proceeding without jitdump",
|
warn_report("Could not map %s: %s, proceeding without jitdump",
|
||||||
|
@ -372,6 +374,11 @@ void perf_exit(void)
|
||||||
perfmap = NULL;
|
perfmap = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (perf_marker != MAP_FAILED) {
|
||||||
|
munmap(perf_marker, perf_marker_size);
|
||||||
|
perf_marker = MAP_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
if (jitdump) {
|
if (jitdump) {
|
||||||
fclose(jitdump);
|
fclose(jitdump);
|
||||||
jitdump = NULL;
|
jitdump = NULL;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue