[PATCH v1] perf record: fix memory leak on AIO objects deallocation
From: Alexey Budankov
Date: Wed Dec 05 2018 - 12:19:49 EST
Sending a part which was missed between v12 and v13 of the patch set
introducing AIO trace streaming for perf record mode.
The part is essential to avoid memory leakage during deallocation
of AIO related trace data buffers.
It is applied on top of acme perf/core repo.
Signed-off-by: Alexey Budankov <alexey.budankov@xxxxxxxxxxxxxxx>
---
tools/perf/util/mmap.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/tools/perf/util/mmap.c b/tools/perf/util/mmap.c
index ab30555d2afc..169d02973757 100644
--- a/tools/perf/util/mmap.c
+++ b/tools/perf/util/mmap.c
@@ -207,8 +207,18 @@ static int perf_mmap__aio_mmap(struct perf_mmap *map, struct mmap_params *mp)
static void perf_mmap__aio_munmap(struct perf_mmap *map)
{
+ int i;
+
+ for (i = 0; i < map->aio.nr_cblocks; ++i) {
+ if (map->aio.data[i])
+ zfree(&map->aio.data[i]);
+ }
if (map->aio.data)
zfree(&map->aio.data);
+ if (map->aio.cblocks)
+ zfree(&map->aio.cblocks);
+ if (map->aio.aiocb)
+ zfree(&map->aio.aiocb);
}
int perf_mmap__aio_push(struct perf_mmap *md, void *to, int idx,