perf record: Fix memory leak on AIO objects deallocation
authorAlexey Budankov <[email protected]>
Wed, 5 Dec 2018 17:19:41 +0000 (20:19 +0300)
committerArnaldo Carvalho de Melo <[email protected]>
Mon, 17 Dec 2018 17:59:34 +0000 (14:59 -0300)
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.

Signed-off-by: Alexey Budankov <[email protected]>
Cc: Alexander Shishkin <[email protected]>
Cc: Andi Kleen <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
[ No need to test for NULL before calling zfree() ]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
tools/perf/util/mmap.c

index ab30555d2afcc5b54d1a59c9fc2b904f5635fbbf..8fc39311a30dc8e480f36ba933e57b8150b6af77 100644 (file)
@@ -207,8 +207,14 @@ 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)
+               zfree(&map->aio.data[i]);
        if (map->aio.data)
                zfree(&map->aio.data);
+       zfree(&map->aio.cblocks);
+       zfree(&map->aio.aiocb);
 }
 
 int perf_mmap__aio_push(struct perf_mmap *md, void *to, int idx,