From: ChenLiang <chenliang88@huawei.com>
To: Chen Gang <gang.chen.5i5j@gmail.com>
Cc: quintela@redhat.com, QEMU Trivial <qemu-trivial@nongnu.org>,
Michael Tokarev <mjt@tls.msk.ru>,
dgilbert@redhat.com, QEMU Developers <qemu-devel@nongnu.org>,
owasserm@redhat.com, arei.gonglei@huawei.com,
Eric Blake <eblake@redhat.com>
Subject: Re: [Qemu-trivial] [Qemu-devel] [PATCH-trivial] arch_init.c: Free 'cache' in cache_fini() to avoid memory leak
Date: Tue, 3 Jun 2014 15:17:33 +0800 [thread overview]
Message-ID: <538D768D.5050904@huawei.com> (raw)
In-Reply-To: <538C6B37.2030400@gmail.com>
On 2014/6/2 20:16, Chen Gang wrote:
> Call g_free() after cache_fini() in migration_end(), but do not call
> g_free() after call cache_fini() in xbzrle_cache_resize() which will
> cause memory leak.
>
> cache_init() and cache_fini() are pair, so need let cache_fini() call
> g_free(cache) to match cache_init(), then fix current issue too.
>
>
> Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
> ---
> arch_init.c | 1 -
> page_cache.c | 1 +
> 2 files changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch_init.c b/arch_init.c
> index 9f1a174..23044c1 100644
> --- a/arch_init.c
> +++ b/arch_init.c
> @@ -739,7 +739,6 @@ static void migration_end(void)
> XBZRLE_cache_lock();
> if (XBZRLE.cache) {
> cache_fini(XBZRLE.cache);
> - g_free(XBZRLE.cache);
> g_free(XBZRLE.encoded_buf);
> g_free(XBZRLE.current_buf);
> XBZRLE.cache = NULL;
> diff --git a/page_cache.c b/page_cache.c
> index b033681..89bb1ec 100644
> --- a/page_cache.c
> +++ b/page_cache.c
> @@ -109,6 +109,7 @@ void cache_fini(PageCache *cache)
>
> g_free(cache->page_cache);
> cache->page_cache = NULL;
> + g_free(cache);
> }
>
> static size_t cache_get_cache_pos(const PageCache *cache,
Reviewed-by: ChenLiang <chenliang88@huawei.com>
WARNING: multiple messages have this Message-ID (diff)
From: ChenLiang <chenliang88@huawei.com>
To: Chen Gang <gang.chen.5i5j@gmail.com>
Cc: quintela@redhat.com, QEMU Trivial <qemu-trivial@nongnu.org>,
Michael Tokarev <mjt@tls.msk.ru>,
dgilbert@redhat.com, QEMU Developers <qemu-devel@nongnu.org>,
owasserm@redhat.com, arei.gonglei@huawei.com
Subject: Re: [Qemu-devel] [PATCH-trivial] arch_init.c: Free 'cache' in cache_fini() to avoid memory leak
Date: Tue, 3 Jun 2014 15:17:33 +0800 [thread overview]
Message-ID: <538D768D.5050904@huawei.com> (raw)
In-Reply-To: <538C6B37.2030400@gmail.com>
On 2014/6/2 20:16, Chen Gang wrote:
> Call g_free() after cache_fini() in migration_end(), but do not call
> g_free() after call cache_fini() in xbzrle_cache_resize() which will
> cause memory leak.
>
> cache_init() and cache_fini() are pair, so need let cache_fini() call
> g_free(cache) to match cache_init(), then fix current issue too.
>
>
> Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
> ---
> arch_init.c | 1 -
> page_cache.c | 1 +
> 2 files changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch_init.c b/arch_init.c
> index 9f1a174..23044c1 100644
> --- a/arch_init.c
> +++ b/arch_init.c
> @@ -739,7 +739,6 @@ static void migration_end(void)
> XBZRLE_cache_lock();
> if (XBZRLE.cache) {
> cache_fini(XBZRLE.cache);
> - g_free(XBZRLE.cache);
> g_free(XBZRLE.encoded_buf);
> g_free(XBZRLE.current_buf);
> XBZRLE.cache = NULL;
> diff --git a/page_cache.c b/page_cache.c
> index b033681..89bb1ec 100644
> --- a/page_cache.c
> +++ b/page_cache.c
> @@ -109,6 +109,7 @@ void cache_fini(PageCache *cache)
>
> g_free(cache->page_cache);
> cache->page_cache = NULL;
> + g_free(cache);
> }
>
> static size_t cache_get_cache_pos(const PageCache *cache,
Reviewed-by: ChenLiang <chenliang88@huawei.com>
next prev parent reply other threads:[~2014-06-03 13:16 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-02 12:16 [Qemu-trivial] [PATCH-trivial] arch_init.c: Free 'cache' in cache_fini() to avoid memory leak Chen Gang
2014-06-02 12:16 ` [Qemu-devel] " Chen Gang
2014-06-03 7:17 ` ChenLiang [this message]
2014-06-03 7:17 ` ChenLiang
2014-06-04 8:16 ` [Qemu-trivial] " Markus Armbruster
2014-06-04 8:16 ` Markus Armbruster
2014-06-04 10:28 ` [Qemu-trivial] " Chen Gang
2014-06-04 10:28 ` Chen Gang
2014-06-04 10:54 ` [Qemu-trivial] " Markus Armbruster
2014-06-04 10:54 ` Markus Armbruster
2014-06-04 11:30 ` [Qemu-trivial] " Chen Gang
2014-06-04 11:30 ` Chen Gang
2014-06-04 9:35 ` [Qemu-trivial] " Dr. David Alan Gilbert
2014-06-04 9:35 ` Dr. David Alan Gilbert
2014-06-08 17:53 ` [Qemu-trivial] " Michael Tokarev
2014-06-08 17:53 ` [Qemu-devel] " Michael Tokarev
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=538D768D.5050904@huawei.com \
--to=chenliang88@huawei.com \
--cc=arei.gonglei@huawei.com \
--cc=dgilbert@redhat.com \
--cc=eblake@redhat.com \
--cc=gang.chen.5i5j@gmail.com \
--cc=mjt@tls.msk.ru \
--cc=owasserm@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@nongnu.org \
--cc=quintela@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.