提交 0fcf00b5 编写于 作者: P Peter Lieven 提交者: Michael Roth

page_cache: fix memory leak

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.
Signed-off-by: NPeter Lieven <pl@kamp.de>
Signed-off-by: NOrit Wasserman <owasserm@redhat.com>
Reviewed-by: NPeter Maydell <peter.maydell@linaro.org>
Signed-off-by: NJuan Quintela <quintela@redhat.com>
(cherry picked from commit 32a1c08b)
Signed-off-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
上级 5610ef58
......@@ -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++;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册