From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41639) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZDAIk-00055m-2X for qemu-devel@nongnu.org; Thu, 09 Jul 2015 07:47:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZDAIg-0005k1-R2 for qemu-devel@nongnu.org; Thu, 09 Jul 2015 07:47:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53278) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZDAIg-0005jx-Lp for qemu-devel@nongnu.org; Thu, 09 Jul 2015 07:47:34 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 482AD8E3E8 for ; Thu, 9 Jul 2015 11:47:34 +0000 (UTC) From: Igor Mammedov Date: Thu, 9 Jul 2015 13:47:22 +0200 Message-Id: <1436442444-132020-6-git-send-email-imammedo@redhat.com> In-Reply-To: <1436442444-132020-1-git-send-email-imammedo@redhat.com> References: <1436442444-132020-1-git-send-email-imammedo@redhat.com> Subject: [Qemu-devel] [PATCH v4 5/7] exec: make sure that RAMBlock descriptor won't be leaked List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, mst@redhat.com HVA remapped file backed RAMBlock shouldn't be freed with munmap() as it will create a hole in HVA area but file descriptor should be freed so it won't leak. Rearrange code so that file descriptor is freed always if it's been used and drop unnecessary munmap() call/branch because qemu_anon_ram_free() is doing the same. Signed-off-by: Igor Mammedov --- exec.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/exec.c b/exec.c index 562dae5..08767ab 100644 --- a/exec.c +++ b/exec.c @@ -1612,14 +1612,14 @@ static void reclaim_ramblock(RAMBlock *block) ; } else if (xen_enabled()) { xen_invalidate_map_cache_entry(block->host); -#ifndef _WIN32 - } else if (block->fd >= 0) { - munmap(block->host, block->max_length); - close(block->fd); -#endif } else { qemu_anon_ram_free(block->host, block->max_length); } +#ifndef _WIN32 + if (block->fd >= 0) { + close(block->fd); + } +#endif g_free(block); } -- 1.8.3.1