From patchwork Mon Feb 25 11:42:01 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Lieven X-Patchwork-Id: 222911 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 7D9E02C02AB for ; Mon, 25 Feb 2013 22:42:19 +1100 (EST) Received: from localhost ([::1]:45645 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U9wRk-0007QT-NE for incoming@patchwork.ozlabs.org; Mon, 25 Feb 2013 06:42:16 -0500 Received: from eggs.gnu.org ([208.118.235.92]:34668) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U9wRa-0007PR-Ne for qemu-devel@nongnu.org; Mon, 25 Feb 2013 06:42:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U9wRX-0005Go-Ii for qemu-devel@nongnu.org; Mon, 25 Feb 2013 06:42:06 -0500 Received: from ssl.dlhnet.de ([91.198.192.8]:52636 helo=ssl.dlh.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U9wRX-0005GW-B6 for qemu-devel@nongnu.org; Mon, 25 Feb 2013 06:42:03 -0500 Received: from localhost (localhost [127.0.0.1]) by ssl.dlh.net (Postfix) with ESMTP id 2BD8414DA8C; Mon, 25 Feb 2013 12:42:02 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at ssl.dlh.net Received: from ssl.dlh.net ([127.0.0.1]) by localhost (ssl.dlh.net [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Q2w22rP69VZR; Mon, 25 Feb 2013 12:42:01 +0100 (CET) Received: from [172.21.12.60] (unknown [82.141.1.226]) by ssl.dlh.net (Postfix) with ESMTPSA id B8C2214D8A5; Mon, 25 Feb 2013 12:42:01 +0100 (CET) Message-ID: <512B4E09.1040908@dlhnet.de> Date: Mon, 25 Feb 2013 12:42:01 +0100 From: Peter Lieven User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130106 Thunderbird/17.0.2 MIME-Version: 1.0 To: "qemu-devel@nongnu.org" X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 91.198.192.8 Cc: Orit Wasserman Subject: [Qemu-devel] [PATCH] page_cache: Fix memory leak X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org XBZRLE encoded migration introduced a MRU page cache meachnism. Unfortunately, cached items where never freed on a collision. This lead to out of memory conditions during XBZRLE migration if the page cache was small and there where a lot of collisions. Signed-off-by: Peter Lieven --- page_cache.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/page_cache.c b/page_cache.c index ba5640b..a6c3a15 100644 --- a/page_cache.c +++ b/page_cache.c @@ -152,8 +152,10 @@ void cache_insert(PageCache *cache, uint64_t addr, uint8_t *pdata) /* actual update of entry */ it = cache_get_by_addr(cache, addr); - if (!it->it_data) { + if (it->it_data == NULL) { cache->num_items++; + } else { + g_free(it->it_data); } it->it_data = pdata;