Skip to content

Commit 4380be0

Browse files
Chen-GangMichael Tokarev
authored and
Michael Tokarev
committed
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: Chen Gang <[email protected]> Reviewed-by: Dr. David Alan Gilbert <[email protected]> Signed-off-by: Michael Tokarev <[email protected]>
1 parent fec0da9 commit 4380be0

File tree

2 files changed

+1
-1
lines changed

2 files changed

+1
-1
lines changed

arch_init.c

-1
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,6 @@ static void migration_end(void)
739739
XBZRLE_cache_lock();
740740
if (XBZRLE.cache) {
741741
cache_fini(XBZRLE.cache);
742-
g_free(XBZRLE.cache);
743742
g_free(XBZRLE.encoded_buf);
744743
g_free(XBZRLE.current_buf);
745744
XBZRLE.cache = NULL;

page_cache.c

+1
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ void cache_fini(PageCache *cache)
109109

110110
g_free(cache->page_cache);
111111
cache->page_cache = NULL;
112+
g_free(cache);
112113
}
113114

114115
static size_t cache_get_cache_pos(const PageCache *cache,

0 commit comments

Comments
 (0)