Skip to content

Commit

Permalink
page_cache: fix memory leak
Browse files Browse the repository at this point in the history
XBZRLE encoded migration introduced a MRU page cache
meachnism. Unfortunately, cached items where never freed in
case of a collision in the page cache on cache_insert().

This lead to out of memory conditions during XBZRLE migration
if the page cache was small and there where a lot of collisions
in the cache.

Signed-off-by: Peter Lieven <pl@kamp.de>
Signed-off-by: Orit Wasserman <owasserm@redhat.com>

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Juan Quintela <quintela@redhat.com>
  • Loading branch information
plieven authored and Juan Quintela committed Mar 11, 2013
1 parent a0ee203 commit 32a1c08
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions page_cache.c
Expand Up @@ -152,6 +152,9 @@ void cache_insert(PageCache *cache, uint64_t addr, uint8_t *pdata)
/* actual update of entry */
it = cache_get_by_addr(cache, addr);

/* free old cached data if any */
g_free(it->it_data);

if (!it->it_data) {
cache->num_items++;
}
Expand Down

0 comments on commit 32a1c08

Please sign in to comment.