]> Git Repo - qemu.git/commitdiff
page_cache: fix memory leak
authorPeter Lieven <[email protected]>
Mon, 25 Feb 2013 17:12:03 +0000 (19:12 +0200)
committerJuan Quintela <[email protected]>
Mon, 11 Mar 2013 12:32:03 +0000 (13:32 +0100)
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 <[email protected]>
Signed-off-by: Orit Wasserman <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Signed-off-by: Juan Quintela <[email protected]>
page_cache.c

index e5717d53c9fb3d5fe2b059e03fa737d11ae3db5b..809dadc7ebf4f6c65d925975569168d84c9a0cc4 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++;
     }
This page took 0.026345 seconds and 4 git commands to generate.