summaryrefslogtreecommitdiff
path: root/tools/perf/util/jitdump.c
diff options
context:
space:
mode:
authorIan Rogers <irogers@google.com>2023-04-03 23:35:45 +0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2023-04-04 19:23:59 +0300
commitdc67c7837a832952459c4f7829e89b9d8d15f420 (patch)
tree26cf51b94d17f955a11c7214595b512a14a3ed3e /tools/perf/util/jitdump.c
parent3ad45105dc44ca8419441032760c04d81504c0e6 (diff)
downloadlinux-dc67c7837a832952459c4f7829e89b9d8d15f420.tar.xz
perf jit: Fix a few memory leaks
As reported by leak sanitizer. Signed-off-by: Ian Rogers <irogers@google.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Brian Robbins <brianrob@linux.microsoft.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Yuan Can <yuancan@huawei.com> Link: https://lore.kernel.org/r/20230403203545.1872196-1-irogers@google.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/jitdump.c')
-rw-r--r--tools/perf/util/jitdump.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/tools/perf/util/jitdump.c b/tools/perf/util/jitdump.c
index 0e033278fa12..28e49502db5e 100644
--- a/tools/perf/util/jitdump.c
+++ b/tools/perf/util/jitdump.c
@@ -235,9 +235,11 @@ jit_open(struct jit_buf_desc *jd, const char *name)
*/
strcpy(jd->dir, name);
dirname(jd->dir);
+ free(buf);
return 0;
error:
+ free(buf);
funlockfile(jd->in);
fclose(jd->in);
return retval;
@@ -523,7 +525,7 @@ static int jit_repipe_code_load(struct jit_buf_desc *jd, union jr_entry *jr)
ret = perf_event__process_mmap2(tool, event, &sample, jd->machine);
if (ret)
- return ret;
+ goto out;
ret = jit_inject_event(jd, event);
/*
@@ -532,6 +534,8 @@ static int jit_repipe_code_load(struct jit_buf_desc *jd, union jr_entry *jr)
if (!ret)
build_id__mark_dso_hit(tool, event, &sample, NULL, jd->machine);
+out:
+ free(event);
return ret;
}
@@ -874,6 +878,7 @@ jit_process(struct perf_session *session,
}
nsinfo__put(jd.nsi);
+ free(jd.buf);
return ret;
}