Skip to contentSkip to conversation

nvdimm: fix memory leak in error code path

PATCH In review Stefan Hajnoczi 4 participants 4 messages Jun 28, 2016 – Jul 6, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nvdimm: fix memory leak in error code path

object_get_canonical_path_component() returns a heap-allocated string that must be freed using g_free().

---
 hw/mem/nvdimm.c | 1 +
 1 file changed, 1 insertion(+)
hw/mem/nvdimm.c +1 -0
index 81896c0..7895805 100644
@@ -98,6 +98,7 @@ static void nvdimm_realize(PCDIMMDevice *dimm, Error **errp)
                    "small to contain nvdimm label (0x%" PRIx64 ") and "
                    "aligned PMEM (0x%" PRIx64 ")",
                    path, memory_region_size(mr), nvdimm->label_size, align);
+        g_free(path);
         return;
     }
 
Signature · 1 line
2.7.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · On Tue, 28 Jun 2016 10:06:46 +0100 Stefan Hajnoczi <[email protected]> wrote:

object_get_canonical_path_component() returns a heap-allocated string that must be freed using g_free().

Quoted 16 lines
---
 hw/mem/nvdimm.c | 1 +
 1 file changed, 1 insertion(+)
hw/mem/nvdimm.c +1 -0
index 81896c0..7895805 100644
@@ -98,6 +98,7 @@ static void nvdimm_realize(PCDIMMDevice *dimm, Error **errp)
                    "small to contain nvdimm label (0x%" PRIx64 ") and "
                    "aligned PMEM (0x%" PRIx64 ")",
                    path, memory_region_size(mr), nvdimm->label_size, align);
+        g_free(path);
         return;
     }
 
#3 lore raw
In reply to Stefan Hajnoczi
Quoted 14 lines · Stefan Hajnoczi

object_get_canonical_path_component() returns a heap-allocated string that must be freed using g_free().

---
 hw/mem/nvdimm.c | 1 +
 1 file changed, 1 insertion(+)
hw/mem/nvdimm.c +0 -0
index 81896c0..7895805 100644

hw/mem/nvdimm.c static void nvdimm_realize(PCDIMMDevice *dimm, Error **errp) · line 103

Quoted 6 lines
hw/mem/nvdimm.c +1 -0
@@ -98,6 +98,7 @@ static void nvdimm_realize(PCDIMMDevice *dimm, Error **errp)
                    "small to contain nvdimm label (0x%" PRIx64 ") and "
                    "aligned PMEM (0x%" PRIx64 ")",
                    path, memory_region_size(mr), nvdimm->label_size, align);
+        g_free(path);
         return;
     }

Michael: Please take this patch through your ACPI tree

Thanks,
Stefan