Skip to contentSkip to conversation

drive mirror:fix memory leak

PATCH Applied Zhang Min 2 participants 2 messages Jan 23, 2014 Block layer

lore
Share & tools
lore

Zhang Min

author
#0 lore raw

PATCH v2 1/1 drive mirror:fix memory leak

In the function mirror_iteration() -> qemu_iovec_init(),
it allocates memory for op->qiov.iov, when the write request calls back, but in the function mirror_iteration_done(), it only frees the op, not free the op->qiov.iov, so this causes memory leak.

It should use qemu_iovec_destroy() to free op->qiov.

---
 block/mirror.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
block/mirror.c +1 -0
index 2932bab..05758e5 100644
@@ -96,6 +96,7 @@ static void mirror_iteration_done(MirrorOp *op, int ret)
         bitmap_set(s->cow_bitmap, chunk_num, nb_chunks);
     }
 
+    qemu_iovec_destroy(&op->qiov);
     g_slice_free(MirrorOp, op);
     qemu_coroutine_enter(s->common.co, NULL);
 }
Signature · 1 line
1.7.3.1.msysgit.0
Applied
#1 lore raw

Am 23.01.2014 um 08:59 hat Zhang Min geschrieben:

Quoted 9 lines

In the function mirror_iteration() -> qemu_iovec_init(),
it allocates memory for op->qiov.iov, when the write request calls back, but in the function mirror_iteration_done(), it only frees the op, not free the op->qiov.iov, so this causes memory leak.

It should use qemu_iovec_destroy() to free op->qiov.

Thanks, applied to the block branch.

Kevin