* [Qemu-devel] [PATCH] drive-mirror:fix memory leak
@ 2014-01-22 7:56 Zhang Min
2014-01-22 8:27 ` Fam Zheng
2014-01-22 9:42 ` Kevin Wolf
0 siblings, 2 replies; 6+ messages in thread
From: Zhang Min @ 2014-01-22 7:56 UTC (permalink / raw)
To: qemu-devel, Fam Zheng
Cc: rudy.zhangmin, Qinling, Chentao (Boby), Wubin (H),
Wangting (Kathy)
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.
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..9840840 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);
}
+ g_free(op->qiov.iov);
g_slice_free(MirrorOp, op);
qemu_coroutine_enter(s->common.co, NULL);
}
--
1.7.3.1.msysgit.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] drive-mirror:fix memory leak
2014-01-22 7:56 [Qemu-devel] [PATCH] drive-mirror:fix memory leak Zhang Min
@ 2014-01-22 8:27 ` Fam Zheng
2014-01-22 9:42 ` Kevin Wolf
1 sibling, 0 replies; 6+ messages in thread
From: Fam Zheng @ 2014-01-22 8:27 UTC (permalink / raw)
To: Zhang Min
Cc: kwolf, Chentao (Boby), Wangting (Kathy), qemu-devel, Qinling,
stefanha, Wubin (H)
On Wed, 01/22 15:56, Zhang Min wrote:
> 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.
>
> 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..9840840 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);
> }
>
> + g_free(op->qiov.iov);
> g_slice_free(MirrorOp, op);
> qemu_coroutine_enter(s->common.co, NULL);
> }
> --
> 1.7.3.1.msysgit.0
>
Reviewed-by: Fam Zheng <famz@redhat.com>
In the future please keep maintainers Cc'ed, as noted in the wiki page, so your
patch can get better chance of being noticed.
http://wiki.qemu.org/Contribute/SubmitAPatch
> Send patches to the mailing list and CC the relevant maintainer -- look in
> the MAINTAINERS file to find out who that is. Also try using
> scripts/getmaintainer.pl from the repository for learning the most common
> committers for the files you touched.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] drive-mirror:fix memory leak
2014-01-22 7:56 [Qemu-devel] [PATCH] drive-mirror:fix memory leak Zhang Min
2014-01-22 8:27 ` Fam Zheng
@ 2014-01-22 9:42 ` Kevin Wolf
1 sibling, 0 replies; 6+ messages in thread
From: Kevin Wolf @ 2014-01-22 9:42 UTC (permalink / raw)
To: Zhang Min
Cc: Fam Zheng, Wangting (Kathy), qemu-devel, Qinling, Chentao (Boby),
Wubin (H)
Am 22.01.2014 um 08:56 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.
>
> 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..9840840 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);
> }
>
> + g_free(op->qiov.iov);
> g_slice_free(MirrorOp, op);
> qemu_coroutine_enter(s->common.co, NULL);
> }
Please use qemu_iovec_destroy() instead. (I would also move it to right
after the for loop that frees the individual buffers in qiov.)
Kevin
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCH] drive-mirror: fix memory leak
@ 2014-01-21 11:43 Chentao (Boby)
2014-01-22 3:41 ` Fam Zheng
0 siblings, 1 reply; 6+ messages in thread
From: Chentao (Boby) @ 2014-01-21 11:43 UTC (permalink / raw)
To: qemu-devel
Cc: Qinling, Zhangmin (Rudy), Wubin (H), Chentao (Boby),
Wangting (Kathy)
[-- Attachment #1: Type: text/plain, Size: 843 bytes --]
In the function mirror_iteration() -> qemu_iovec_init(), it alloc memory for op->qiov.iov, when the write request call back,
but in the function mirror_iteration_done(), it only free the op, not free the op->qiov.iov, so this cause memory leak.
Signed-off-by: Zhang Min <rudy.zhangmin@huawei.com<mailto: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..9840840 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);
}
+ g_free(op->qiov.iov);
g_slice_free(MirrorOp, op);
qemu_coroutine_enter(s->common.co, NULL); }
--
[-- Attachment #2: Type: text/html, Size: 4613 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] drive-mirror: fix memory leak
2014-01-21 11:43 [Qemu-devel] [PATCH] drive-mirror: fix " Chentao (Boby)
@ 2014-01-22 3:41 ` Fam Zheng
2014-01-22 6:53 ` Zhang Min
0 siblings, 1 reply; 6+ messages in thread
From: Fam Zheng @ 2014-01-22 3:41 UTC (permalink / raw)
To: Chentao (Boby)
Cc: Zhangmin (Rudy), Qinling, qemu-devel, Wubin (H), Wangting (Kathy)
Hi,
The patch itself looks good to me, but it has too many extra empty lines
interleaved. Please try to use "git send-email" to submit your patches, for
more information, follow the instructions as in:
http://wiki.qemu.org/Contribute/SubmitAPatch
On Tue, 01/21 11:43, Chentao (Boby) wrote:
> In the function mirror_iteration() -> qemu_iovec_init(), it alloc memory for op->qiov.iov, when the write request call back,
s/alloc/allocates/
s/call back/calls back/
>
>
>
> but in the function mirror_iteration_done(), it only free the op, not free the op->qiov.iov, so this cause memory leak.
s/free/frees/
s/cause/causes/
>
>
>
> Signed-off-by: Zhang Min <rudy.zhangmin@huawei.com<mailto:rudy.zhangmin@huawei.com>>
Unnecessary <mailto:> notation here.
>
> ---
>
> block/mirror.c | 1 +
>
> 1 files changed, 1 insertions(+), 0 deletions(-)
>
>
>
> diff --git a/block/mirror.c b/block/mirror.c index 2932bab..9840840 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);
>
> }
>
>
>
> + g_free(op->qiov.iov);
>
> g_slice_free(MirrorOp, op);
>
> qemu_coroutine_enter(s->common.co, NULL); }
>
> --
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] drive-mirror: fix memory leak
2014-01-22 3:41 ` Fam Zheng
@ 2014-01-22 6:53 ` Zhang Min
0 siblings, 0 replies; 6+ messages in thread
From: Zhang Min @ 2014-01-22 6:53 UTC (permalink / raw)
To: Fam Zheng, Chentao (Boby), qemu-devel
Cc: Qinling, Wubin (H), Wangting (Kathy)
Hi,Fam
I am very sorry for this patch,because I use Outlook to send this email.
Later on, I will submit the patch by git send-email again.
On 2014/1/22 11:41, Fam Zheng wrote:
> Hi,
>
> The patch itself looks good to me, but it has too many extra empty lines
> interleaved. Please try to use "git send-email" to submit your patches, for
> more information, follow the instructions as in:
>
> http://wiki.qemu.org/Contribute/SubmitAPatch
>
> On Tue, 01/21 11:43, Chentao (Boby) wrote:
>> In the function mirror_iteration() -> qemu_iovec_init(), it alloc memory for op->qiov.iov, when the write request call back,
>
> s/alloc/allocates/
> s/call back/calls back/
>
>>
>>
>>
>> but in the function mirror_iteration_done(), it only free the op, not free the op->qiov.iov, so this cause memory leak.
>
> s/free/frees/
> s/cause/causes/
>
>>
>>
>>
>> Signed-off-by: Zhang Min <rudy.zhangmin@huawei.com<mailto:rudy.zhangmin@huawei.com>>
>
> Unnecessary <mailto:> notation here.
>
>>
>> ---
>>
>> block/mirror.c | 1 +
>>
>> 1 files changed, 1 insertions(+), 0 deletions(-)
>>
>>
>>
>> diff --git a/block/mirror.c b/block/mirror.c index 2932bab..9840840 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);
>>
>> }
>>
>>
>>
>> + g_free(op->qiov.iov);
>>
>> g_slice_free(MirrorOp, op);
>>
>> qemu_coroutine_enter(s->common.co, NULL); }
>>
>> --
>>
>>
>
>
--
Zhang Min
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-01-22 9:43 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-22 7:56 [Qemu-devel] [PATCH] drive-mirror:fix memory leak Zhang Min
2014-01-22 8:27 ` Fam Zheng
2014-01-22 9:42 ` Kevin Wolf
-- strict thread matches above, loose matches on Subject: below --
2014-01-21 11:43 [Qemu-devel] [PATCH] drive-mirror: fix " Chentao (Boby)
2014-01-22 3:41 ` Fam Zheng
2014-01-22 6:53 ` Zhang Min
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).