qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH v4 5/7] exec: make sure that RAMBlock descriptor won


From: Igor Mammedov
Subject: [Qemu-devel] [PATCH v4 5/7] exec: make sure that RAMBlock descriptor won't be leaked
Date: Thu, 9 Jul 2015 13:47:22 +0200

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 <address@hidden>
---
 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]