From 8a9e0e7b890b2598da94646bf6a7272f3d3924de Mon Sep 17 00:00:00 2001 From: Greg Kurz Date: Tue, 6 Jun 2017 17:22:58 +0200 Subject: spapr: fix memory leak in spapr_memory_pre_plug() The string returned by object_property_get_str() is dynamically allocated. (Spotted by Coverity, CID 1375942) Signed-off-by: Greg Kurz Signed-off-by: David Gibson --- hw/ppc/spapr.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 91b4057933..9b7ae28939 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2615,8 +2615,11 @@ static void spapr_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev, if (mem_dev && !kvmppc_is_mem_backend_page_size_ok(mem_dev)) { error_setg(errp, "Memory backend has bad page size. " "Use 'memory-backend-file' with correct mem-path."); - return; + goto out; } + +out: + g_free(mem_dev); } struct sPAPRDIMMState { -- cgit v1.2.3