diff mbox

nvdimm: fix memory leak in error code path

Message ID 1467104806-3461-1-git-send-email-stefanha@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Stefan Hajnoczi June 28, 2016, 9:06 a.m. UTC
object_get_canonical_path_component() returns a heap-allocated string
that must be freed using g_free().

Reported-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 hw/mem/nvdimm.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Igor Mammedov June 28, 2016, 9:10 a.m. UTC | #1
On Tue, 28 Jun 2016 10:06:46 +0100
Stefan Hajnoczi <stefanha@redhat.com> wrote:

> object_get_canonical_path_component() returns a heap-allocated string
> that must be freed using g_free().
> 
> Reported-by: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>

Reviewed-by: Igor Mammedov <imammedo@redhat.com>

> ---
>  hw/mem/nvdimm.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/hw/mem/nvdimm.c b/hw/mem/nvdimm.c
> index 81896c0..7895805 100644
> --- a/hw/mem/nvdimm.c
> +++ b/hw/mem/nvdimm.c
> @@ -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;
>      }
>
Xiao Guangrong June 28, 2016, 9:20 a.m. UTC | #2
On 06/28/2016 05:06 PM, Stefan Hajnoczi wrote:
> object_get_canonical_path_component() returns a heap-allocated string
> that must be freed using g_free().
>

Reviewed-by: Xiao Guangrong <guangrong.xiao@linux.intel.com>

Thanks for your fix and thank Paolo for the report.
Stefan Hajnoczi July 6, 2016, 3:52 p.m. UTC | #3
On Tue, Jun 28, 2016 at 10:06:46AM +0100, Stefan Hajnoczi wrote:
> object_get_canonical_path_component() returns a heap-allocated string
> that must be freed using g_free().
> 
> Reported-by: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
>  hw/mem/nvdimm.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/hw/mem/nvdimm.c b/hw/mem/nvdimm.c
> index 81896c0..7895805 100644
> --- a/hw/mem/nvdimm.c
> +++ b/hw/mem/nvdimm.c
> @@ -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
diff mbox

Patch

diff --git a/hw/mem/nvdimm.c b/hw/mem/nvdimm.c
index 81896c0..7895805 100644
--- a/hw/mem/nvdimm.c
+++ b/hw/mem/nvdimm.c
@@ -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;
     }