qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2] drive mirror:fix memory leak
@ 2014-01-23  7:59 Zhang Min
  2014-01-23 10:51 ` Kevin Wolf
  0 siblings, 1 reply; 2+ messages in thread
From: Zhang Min @ 2014-01-23  7:59 UTC (permalink / raw)
  To: qemu-devel
  Cc: kwolf, Fam Zheng, Wangting (Kathy), Stefan Hajnoczi, Qinling,
	Chentao (Boby), Paolo Bonzini, Wubin (H)


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.

Signed-off-by: Zhang Min <rudy.zhangmin@huawei.com>
---
 block/mirror.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/block/mirror.c b/block/mirror.c
index 2932bab..05758e5 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -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);
 }
-- 
1.7.3.1.msysgit.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] [PATCH v2] drive mirror:fix memory leak
  2014-01-23  7:59 [Qemu-devel] [PATCH v2] drive mirror:fix memory leak Zhang Min
@ 2014-01-23 10:51 ` Kevin Wolf
  0 siblings, 0 replies; 2+ messages in thread
From: Kevin Wolf @ 2014-01-23 10:51 UTC (permalink / raw)
  To: Zhang Min
  Cc: Fam Zheng, Wangting (Kathy), Stefan Hajnoczi, qemu-devel, Qinling,
	Chentao (Boby), Paolo Bonzini, Wubin (H)

Am 23.01.2014 um 08:59 hat Zhang Min geschrieben:
> 
> 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.
> 
> Signed-off-by: Zhang Min <rudy.zhangmin@huawei.com>

Thanks, applied to the block branch.

Kevin

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-01-23 10:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-23  7:59 [Qemu-devel] [PATCH v2] drive mirror:fix memory leak Zhang Min
2014-01-23 10:51 ` Kevin Wolf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).