提交 4380be0e 编写于 作者: C Chen Gang 提交者: Michael Tokarev

migration: Plug memory leak in migrate-set-cache-size command

We call g_free() after cache_fini() in migration_end(), but we don't
call it after cache_fini() in xbzrle_cache_resize(), leaking the
memory.

cache_init() and cache_fini() are a pair.  Since cache_init()
allocates the cache, let cache_fini() free it.  This plugs the leak.
Signed-off-by: NChen Gang <gang.chen.5i5j@gmail.com>
Reviewed-by: NDr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: NMichael Tokarev <mjt@tls.msk.ru>
上级 fec0da9c
......@@ -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;
......
......@@ -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,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册