[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH-trivial] arch_init.c: Free 'cache' in cache_fini
From: |
ChenLiang |
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 |
User-agent: |
Mozilla/5.0 (Windows NT 6.1; rv:11.0) Gecko/20120327 Thunderbird/11.0.1 |
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 <address@hidden>
> ---
> 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 <address@hidden>