[CRIU] [PATCH] aio: don't leak memory

Andrey Vagin avagin at openvz.org
Thu Jun 9 14:10:01 PDT 2016


From: Andrew Vagin <avagin at virtuozzo.com>

CID 161664 (#1 of 1): Resource leak (RESOURCE_LEAK)
11. leaked_storage: Variable re going out of scope leaks the storage it points to.

Signed-off-by: Andrew Vagin <avagin at virtuozzo.com>
---
 criu/aio.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/criu/aio.c b/criu/aio.c
index ad15492..540fe64 100644
--- a/criu/aio.c
+++ b/criu/aio.c
@@ -31,8 +31,10 @@ int dump_aio_ring(MmEntry *mme, struct vma_area *vma)
 	re->id = vma->e->start;
 	re->ring_len = vma->e->end - vma->e->start;
 	re->nr_req = aio_estimate_nr_reqs(re->ring_len);
-	if (!re->nr_req)
+	if (!re->nr_req) {
+		xfree(re);
 		return -1;
+	}
 	mme->aios[nr] = re;
 	mme->n_aios = nr + 1;
 	pr_info("Dumping AIO ring @%"PRIx64"-%"PRIx64"\n",
-- 
2.7.4



More information about the CRIU mailing list