[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 23/25] migration: Plug memory leak in migrate-set-cac
From: |
Michael Tokarev |
Subject: |
[Qemu-devel] [PULL 23/25] migration: Plug memory leak in migrate-set-cache-size command |
Date: |
Tue, 10 Jun 2014 20:08:41 +0400 |
From: Chen Gang <address@hidden>
We call g_free() after cache_fini() in migration_end(), but we don't
call it after cache_fini() in xbzrle_cache_resize(), leaking the
memory.
cache_init() and cache_fini() are a pair. Since cache_init()
allocates the cache, let cache_fini() free it. This plugs the leak.
Signed-off-by: Chen Gang <address@hidden>
Reviewed-by: Dr. David Alan Gilbert <address@hidden>
Signed-off-by: Michael Tokarev <address@hidden>
---
arch_init.c | 1 -
page_cache.c | 1 +
2 files changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch_init.c b/arch_init.c
index 9f1a174..23044c1 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -739,7 +739,6 @@ static void migration_end(void)
XBZRLE_cache_lock();
if (XBZRLE.cache) {
cache_fini(XBZRLE.cache);
- g_free(XBZRLE.cache);
g_free(XBZRLE.encoded_buf);
g_free(XBZRLE.current_buf);
XBZRLE.cache = NULL;
diff --git a/page_cache.c b/page_cache.c
index b033681..89bb1ec 100644
--- a/page_cache.c
+++ b/page_cache.c
@@ -109,6 +109,7 @@ void cache_fini(PageCache *cache)
g_free(cache->page_cache);
cache->page_cache = NULL;
+ g_free(cache);
}
static size_t cache_get_cache_pos(const PageCache *cache,
--
1.7.10.4
- [Qemu-devel] [PULL 00/25] Trivial patches for 2014-06-10, Michael Tokarev, 2014/06/10
- [Qemu-devel] [PULL 02/25] net: cadence_gem: Add Tx descriptor fetch printf, Michael Tokarev, 2014/06/10
- [Qemu-devel] [PULL 06/25] slirp: Remove unused zero_ethaddr[] variable, Michael Tokarev, 2014/06/10
- [Qemu-devel] [PULL 05/25] qtest: fix hex2nib for capital characters, Michael Tokarev, 2014/06/10
- [Qemu-devel] [PULL 04/25] net: cadence_gem: Remove &desc[0] usages, Michael Tokarev, 2014/06/10
- [Qemu-devel] [PULL 10/25] hw/dma/xilinx_axidma: Remove unused stream_halted() function, Michael Tokarev, 2014/06/10
- [Qemu-devel] [PULL 19/25] smbios: use g_free directly on NULL pointers, Michael Tokarev, 2014/06/10
- [Qemu-devel] [PULL 22/25] libcacard: Clean up dead stores before g_free(), Michael Tokarev, 2014/06/10
- [Qemu-devel] [PULL 23/25] migration: Plug memory leak in migrate-set-cache-size command,
Michael Tokarev <=
- [Qemu-devel] [PULL 21/25] libcacard: Drop superfluous conditionals around g_free(), Michael Tokarev, 2014/06/10
- [Qemu-devel] [PULL 17/25] apb: Fix compiler warnings (large constants), Michael Tokarev, 2014/06/10
- [Qemu-devel] [PULL 14/25] hw/misc/milkymist-softusb: Remove unused softusb_{read, write}_pmem(), Michael Tokarev, 2014/06/10
- [Qemu-devel] [PULL 24/25] hw: vmware_vga: don't return cursorx when the driver asks for cursory register, Michael Tokarev, 2014/06/10
- [Qemu-devel] [PULL 01/25] net: cadence_gem: Fix Tx descriptor update, Michael Tokarev, 2014/06/10
- [Qemu-devel] [PULL 12/25] hw/isa/pc87312: Remove unused function is_parallel_epp(), Michael Tokarev, 2014/06/10
- [Qemu-devel] [PULL 03/25] net: cadence_gem: Comment spelling sweep, Michael Tokarev, 2014/06/10
- [Qemu-devel] [PULL 18/25] vdi: remove double conversion, Michael Tokarev, 2014/06/10
- [Qemu-devel] [PULL 11/25] hw/intc/openpic: Remove unused function IRQ_testbit(), Michael Tokarev, 2014/06/10
- [Qemu-devel] [PULL 13/25] target-i386/translate.c: Remove unused tcg_gen_lshift(), Michael Tokarev, 2014/06/10