diff options
author | Peter Lieven <pl@dlhnet.de> | 2013-02-25 19:12:03 +0200 |
---|---|---|
committer | Juan Quintela <quintela@redhat.com> | 2013-03-11 13:32:03 +0100 |
commit | 32a1c08b60a8ac0e63b54a5793a26b5e32b36618 (patch) | |
tree | a3f661821a22ae465dd00a8a19fd0b20c7c060ee | |
parent | a0ee2031dbf5f0183412d4b20a30cbfd404616a8 (diff) |
page_cache: fix memory leak
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>
-rw-r--r-- | page_cache.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/page_cache.c b/page_cache.c index e5717d53c9..809dadc7eb 100644 --- a/page_cache.c +++ b/page_cache.c @@ -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++; } |