aio: don't leak memory

Submitted by Andrei Vagin on June 9, 2016, 9:10 p.m.

Details

Message ID 1465506601-19558-1-git-send-email-avagin@openvz.org
State Accepted
Series "aio: don't leak memory"
Commit 9fb1e55bfbb8cfbde3c672c09bfe09d672d8e484
Headers show

Commit Message

Andrei Vagin June 9, 2016, 9:10 p.m.
From: Andrew Vagin <avagin@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@virtuozzo.com>
---
 criu/aio.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

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",

Comments

Pavel Emelianov June 15, 2016, 11:35 a.m.
Applied