Received: from eggs.gnu.org ([2001:4830:134:3::10]:56105) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WthHY-0000UT-Ee for qemu-devel@nongnu.org; Sun, 08 Jun 2014 13:53:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WthHS-0005Qp-9j for qemu-devel@nongnu.org; Sun, 08 Jun 2014 13:53:24 -0400 Message-ID: <5394A309.2010808@msgid.tls.msk.ru> Date: Sun, 08 Jun 2014 21:53:13 +0400 From: Michael Tokarev MIME-Version: 1.0 References: <538C6B37.2030400@gmail.com> In-Reply-To: <538C6B37.2030400@gmail.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [Qemu-trivial] [PATCH-trivial] arch_init.c: Free 'cache' in cache_fini() to avoid memory leak List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Chen Gang , quintela@redhat.com, arei.gonglei@huawei.com, Eric Blake , dgilbert@redhat.com, owasserm@redhat.com Cc: QEMU Trivial , QEMU Developers 02.06.2014 16:16, Chen Gang wrote: > Call g_free() after cache_fini() in migration_end(), but do not call > g_free() after call cache_fini() in xbzrle_cache_resize() which will > cause memory leak. > > cache_init() and cache_fini() are pair, so need let cache_fini() call > g_free(cache) to match cache_init(), then fix current issue too. Applied to -trivial, with the following commit message: migration: Plug memory leak in migrate-set-cache-size command 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. Thanks, /mjt