]> git.proxmox.com Git - qemu.git/commitdiff
page_cache: fix memory leak
authorPeter Lieven <pl@dlhnet.de>
Mon, 25 Feb 2013 17:12:03 +0000 (19:12 +0200)
committerMichael Roth <mdroth@linux.vnet.ibm.com>
Tue, 2 Apr 2013 20:44:43 +0000 (15:44 -0500)
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>
(cherry picked from commit 32a1c08b60a8ac0e63b54a5793a26b5e32b36618)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
page_cache.c

index 748957bc421a3a1545ed94c4f3e37d3b740e3c54..b92482c50d1b71512781fc3db6ae6fe920cc5538 100644 (file)
@@ -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++;
     }