Skip to content

Commit

Permalink
migration: Plug memory leak in migrate-set-cache-size command
Browse files Browse the repository at this point in the history
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 <gang.chen.5i5j@gmail.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
  • Loading branch information
Chen-Gang authored and Michael Tokarev committed Jun 10, 2014
1 parent fec0da9 commit 4380be0
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 1 deletion.
1 change: 0 additions & 1 deletion arch_init.c
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions page_cache.c
Expand Up @@ -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,
Expand Down

0 comments on commit 4380be0

Please sign in to comment.