From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57084) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gFfmu-000259-5d for qemu-devel@nongnu.org; Thu, 25 Oct 2018 09:35:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gFflP-0006hC-GU for qemu-devel@nongnu.org; Thu, 25 Oct 2018 09:33:31 -0400 From: Eduardo Habkost Date: Thu, 25 Oct 2018 10:32:19 -0300 Message-Id: <20181025133301.16578-2-ehabkost@redhat.com> In-Reply-To: <20181025133301.16578-1-ehabkost@redhat.com> References: <20181025133301.16578-1-ehabkost@redhat.com> Subject: [Qemu-devel] [PULL v2 01/43] hostmem-file: fixed the memory leak while get pmem path. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell , qemu-devel@nongnu.org Cc: Paolo Bonzini , Alexander Graf , Rob Herring , libvir-list@redhat.com, Richard Henderson , David Gibson , Eric Blake , Igor Mammedov , qemu-arm@nongnu.org, "Edgar E. Iglesias" , Peter Crosthwaite , Markus Armbruster , Artyom Tarasenko , Mark Cave-Ayland , Eduardo Habkost , Michael Walle , Thomas Huth , Marcel Apfelbaum , Aleksandar Markovic , Aurelien Jarno , Alistair Francis , "Michael S. Tsirkin" , Jason Wang , Laurent Vivier , qemu-ppc@nongnu.org, Xiao Guangrong , Max Filippov , Zhang Yi From: Zhang Yi object_get_canonical_path_component() returns a string which must be freed using g_free(). Reported-by: Peter Maydell Signed-off-by: Michael S. Tsirkin Signed-off-by: Zhang Yi Message-Id: <7328fb16c394eaf5d65437d11c2a9343647b6d3d.1535471899.git.yi.z.zhang@linux.intel.com> Reviewed-by: Eduardo Habkost Signed-off-by: Eduardo Habkost --- backends/hostmem-file.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/backends/hostmem-file.c b/backends/hostmem-file.c index e64074954f..639c8d4307 100644 --- a/backends/hostmem-file.c +++ b/backends/hostmem-file.c @@ -145,20 +145,26 @@ static void file_memory_backend_set_pmem(Object *o, bool value, Error **errp) HostMemoryBackendFile *fb = MEMORY_BACKEND_FILE(o); if (host_memory_backend_mr_inited(backend)) { + char *path = object_get_canonical_path_component(o); + error_setg(errp, "cannot change property 'pmem' of %s '%s'", object_get_typename(o), - object_get_canonical_path_component(o)); + path); + g_free(path); return; } #ifndef CONFIG_LIBPMEM if (value) { Error *local_err = NULL; + char *path = object_get_canonical_path_component(o); + error_setg(&local_err, "Lack of libpmem support while setting the 'pmem=on'" " of %s '%s'. We can't ensure data persistence.", object_get_typename(o), - object_get_canonical_path_component(o)); + path); + g_free(path); error_propagate(errp, local_err); return; } -- 2.18.0.rc1.1.g3f1ff2140