From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45613) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aoD9C-00041a-La for qemu-devel@nongnu.org; Thu, 07 Apr 2016 12:51:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aoD99-0001d4-IM for qemu-devel@nongnu.org; Thu, 07 Apr 2016 12:51:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34576) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aoD99-0001cx-Cx for qemu-devel@nongnu.org; Thu, 07 Apr 2016 12:51:07 -0400 From: Paolo Bonzini Date: Thu, 7 Apr 2016 18:50:42 +0200 Message-Id: <1460047845-14488-13-git-send-email-pbonzini@redhat.com> In-Reply-To: <1460047845-14488-1-git-send-email-pbonzini@redhat.com> References: <1460047845-14488-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PULL 12/15] hostmem-file: fix memory leak List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gonglei From: Gonglei Signed-off-by: Gonglei Message-Id: <1456998223-12356-5-git-send-email-arei.gonglei@huawei.com> Signed-off-by: Paolo Bonzini --- backends/hostmem-file.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/backends/hostmem-file.c b/backends/hostmem-file.c index c70f268..b17a1f1 100644 --- a/backends/hostmem-file.c +++ b/backends/hostmem-file.c @@ -52,11 +52,14 @@ file_backend_memory_alloc(HostMemoryBackend *backend, Error **errp) error_setg(errp, "-mem-path not supported on this host"); #else if (!memory_region_size(&backend->mr)) { + gchar *path; backend->force_prealloc = mem_prealloc; + path = object_get_canonical_path(OBJECT(backend)); memory_region_init_ram_from_file(&backend->mr, OBJECT(backend), - object_get_canonical_path(OBJECT(backend)), + path, backend->size, fb->share, fb->mem_path, errp); + g_free(path); } #endif } -- 2.5.5