From: zhanghailiang <zhang.zhanghailiang@huawei.com>
To: jasowang@redhat.com, zhangchen.fnst@cn.fujitsu.com
Cc: qemu-devel@nongnu.org, weidong.huang@huawei.com,
zhanghailiang <zhang.zhanghailiang@huawei.com>
Subject: [Qemu-devel] [PATCH 3/3] colo-compare: fix a memory leak
Date: Thu, 20 Apr 2017 15:46:55 +0800 [thread overview]
Message-ID: <1492674416-9408-4-git-send-email-zhang.zhanghailiang@huawei.com> (raw)
In-Reply-To: <1492674416-9408-1-git-send-email-zhang.zhanghailiang@huawei.com>
g_timeout_source_new() will initialize GSource's reference count to 1,
and g_source_attach() will increase the count by 1, so it will not be
enough to call just g_source_unref() which only reduce the value by 1.
It will lead to memory leak.
We need to call g_source_destroy() before g_source_unref().
Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
---
net/colo-compare.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/net/colo-compare.c b/net/colo-compare.c
index d6a5e4c..97bf0e5 100644
--- a/net/colo-compare.c
+++ b/net/colo-compare.c
@@ -562,7 +562,9 @@ static void *colo_compare_thread(void *opaque)
g_main_loop_run(s->compare_loop);
+ g_source_destroy(timeout_source);
g_source_unref(timeout_source);
+
g_main_loop_unref(s->compare_loop);
g_main_context_unref(s->worker_context);
return NULL;
--
1.8.3.1
prev parent reply other threads:[~2017-04-20 7:47 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-20 7:46 [Qemu-devel] [PATCH 0/3] colo-compare: fix three bugs zhanghailiang
2017-04-20 7:46 ` [Qemu-devel] [PATCH 1/3] colo-compare: serialize compare thread's initialization with main thread zhanghailiang
2017-04-24 4:10 ` Jason Wang
2017-04-24 6:03 ` Hailiang Zhang
2017-04-25 8:41 ` Jason Wang
2017-04-25 9:59 ` Hailiang Zhang
2017-04-25 11:33 ` Jason Wang
2017-04-26 7:51 ` Hailiang Zhang
2017-05-04 2:51 ` Hailiang Zhang
2017-05-05 3:03 ` Jason Wang
2017-04-20 7:46 ` [Qemu-devel] [PATCH 2/3] colo-compare: Check main_loop value before call g_main_loop_quit zhanghailiang
2017-04-24 4:13 ` Jason Wang
2017-04-24 6:06 ` Hailiang Zhang
2017-04-20 7:46 ` zhanghailiang [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1492674416-9408-4-git-send-email-zhang.zhanghailiang@huawei.com \
--to=zhang.zhanghailiang@huawei.com \
--cc=jasowang@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=weidong.huang@huawei.com \
--cc=zhangchen.fnst@cn.fujitsu.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).