From patchwork Mon Feb 25 13:19:41 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Orit Wasserman X-Patchwork-Id: 222918 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 0229D2C02BA for ; Tue, 26 Feb 2013 00:36:51 +1100 (EST) Received: from localhost ([::1]:58766 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U9yEY-0002l5-0N for incoming@patchwork.ozlabs.org; Mon, 25 Feb 2013 08:36:46 -0500 Received: from eggs.gnu.org ([208.118.235.92]:52297) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U9yEL-0002gI-Dj for qemu-devel@nongnu.org; Mon, 25 Feb 2013 08:36:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U9yEJ-0007vN-N2 for qemu-devel@nongnu.org; Mon, 25 Feb 2013 08:36:33 -0500 Received: from mx1.redhat.com ([209.132.183.28]:15464) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U9xxA-0001xU-Vj for qemu-devel@nongnu.org; Mon, 25 Feb 2013 08:18:49 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r1PDIhcU007699 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 25 Feb 2013 08:18:43 -0500 Received: from dhcp-1-120.tlv.redhat.com (vpn-200-236.tlv.redhat.com [10.35.200.236]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r1PDIXfR004585; Mon, 25 Feb 2013 08:18:41 -0500 From: Orit Wasserman To: qemu-devel@nongnu.org Date: Mon, 25 Feb 2013 15:19:41 +0200 Message-Id: <1361798382-6515-4-git-send-email-owasserm@redhat.com> In-Reply-To: <1361798382-6515-1-git-send-email-owasserm@redhat.com> References: <1361798382-6515-1-git-send-email-owasserm@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: peter.maydell@linaro.org, pl@kamp.de, Peter Lieven , Orit Wasserman Subject: [Qemu-devel] [PATCH 3/4] 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 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. From: Peter Lieven Signed-off-by: Peter Lieven Signed-off-by: Orit Wasserman --- page_cache.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/page_cache.c b/page_cache.c index 21a4cde..07da547 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++; }