From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:37420) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UN97m-0000s9-SW for qemu-devel@nongnu.org; Tue, 02 Apr 2013 17:52:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UN97k-0000UO-Ap for qemu-devel@nongnu.org; Tue, 02 Apr 2013 17:52:14 -0400 Sender: fluxion From: Michael Roth Date: Tue, 2 Apr 2013 16:45:35 -0500 Message-Id: <1364939142-30066-31-git-send-email-mdroth@linux.vnet.ibm.com> In-Reply-To: <1364939142-30066-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1364939142-30066-1-git-send-email-mdroth@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH 30/37] page_cache: fix memory leak List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org From: Peter Lieven 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 Signed-off-by: Orit Wasserman Reviewed-by: Peter Maydell Signed-off-by: Juan Quintela (cherry picked from commit 32a1c08b60a8ac0e63b54a5793a26b5e32b36618) Signed-off-by: Michael Roth --- page_cache.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/page_cache.c b/page_cache.c index 748957b..b92482c 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++; } -- 1.7.9.5