[PATCH 04/12] elf2dmp/pdb: Plug memleak in pdb_init_from_file

Pan Nengyuan posted 12 patches 5 years, 5 months ago
Maintainers: Gerd Hoffmann <kraxel@redhat.com>, Halil Pasic <pasic@linux.ibm.com>, Max Reitz <mreitz@redhat.com>, "Dr. David Alan Gilbert" <dgilbert@redhat.com>, Pierre Morel <pmorel@linux.ibm.com>, Eduardo Habkost <ehabkost@redhat.com>, Hailiang Zhang <zhang.zhanghailiang@huawei.com>, Thomas Huth <thuth@redhat.com>, Tony Krowiak <akrowiak@linux.ibm.com>, Kevin Wolf <kwolf@redhat.com>, Viktor Prutyanov <viktor.prutyanov@phystech.edu>, Markus Armbruster <armbru@redhat.com>, Richard Henderson <rth@twiddle.net>, Alex Williamson <alex.williamson@redhat.com>, Christian Borntraeger <borntraeger@de.ibm.com>, Michael Roth <mdroth@linux.vnet.ibm.com>, Paolo Bonzini <pbonzini@redhat.com>, Cornelia Huck <cohuck@redhat.com>, Juan Quintela <quintela@redhat.com>
There is a newer version of this series
[PATCH 04/12] elf2dmp/pdb: Plug memleak in pdb_init_from_file
Posted by Pan Nengyuan 5 years, 5 months ago
Missing g_error_free in pdb_init_from_file() error path. Fix that.

Reported-by: Euler Robot <euler.robot@huawei.com>
Signed-off-by: Pan Nengyuan <pannengyuan@huawei.com>
---
Cc: Viktor Prutyanov <viktor.prutyanov@phystech.edu>
---
 contrib/elf2dmp/pdb.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/contrib/elf2dmp/pdb.c b/contrib/elf2dmp/pdb.c
index a5bd40c99d..b3a6547068 100644
--- a/contrib/elf2dmp/pdb.c
+++ b/contrib/elf2dmp/pdb.c
@@ -285,6 +285,7 @@ int pdb_init_from_file(const char *name, struct pdb_reader *reader)
     reader->gmf = g_mapped_file_new(name, TRUE, &gerr);
     if (gerr) {
         eprintf("Failed to map PDB file \'%s\'\n", name);
+        g_error_free(gerr);
         return 1;
     }
 
-- 
2.18.2


Re: [PATCH 04/12] elf2dmp/pdb: Plug memleak in pdb_init_from_file
Posted by Viktor Prutyanov 5 years, 5 months ago
On Fri, 14 Aug 2020 12:02:33 -0400
Pan Nengyuan <pannengyuan@huawei.com> wrote:

> Missing g_error_free in pdb_init_from_file() error path. Fix that.
> 
> Reported-by: Euler Robot <euler.robot@huawei.com>
> Signed-off-by: Pan Nengyuan <pannengyuan@huawei.com>
> ---
> Cc: Viktor Prutyanov <viktor.prutyanov@phystech.edu>
> ---
>  contrib/elf2dmp/pdb.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/contrib/elf2dmp/pdb.c b/contrib/elf2dmp/pdb.c
> index a5bd40c99d..b3a6547068 100644
> --- a/contrib/elf2dmp/pdb.c
> +++ b/contrib/elf2dmp/pdb.c
> @@ -285,6 +285,7 @@ int pdb_init_from_file(const char *name, struct
> pdb_reader *reader) reader->gmf = g_mapped_file_new(name, TRUE,
> &gerr); if (gerr) {
>          eprintf("Failed to map PDB file \'%s\'\n", name);
> +        g_error_free(gerr);
>          return 1;
>      }
>  

Reviewed-by: Viktor Prutyanov <viktor.prutyanov@phystech.edu>

-- 
Viktor Prutyanov

Re: [PATCH 04/12] elf2dmp/pdb: Plug memleak in pdb_init_from_file
Posted by Li Qiang 5 years, 5 months ago
Pan Nengyuan <pannengyuan@huawei.com> 于2020年8月14日周五 下午6:51写道:
>
> Missing g_error_free in pdb_init_from_file() error path. Fix that.
>
> Reported-by: Euler Robot <euler.robot@huawei.com>
> Signed-off-by: Pan Nengyuan <pannengyuan@huawei.com>

Reviewed-by: Li Qiang <liq3ea@gmail.com>

> ---
> Cc: Viktor Prutyanov <viktor.prutyanov@phystech.edu>
> ---
>  contrib/elf2dmp/pdb.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/contrib/elf2dmp/pdb.c b/contrib/elf2dmp/pdb.c
> index a5bd40c99d..b3a6547068 100644
> --- a/contrib/elf2dmp/pdb.c
> +++ b/contrib/elf2dmp/pdb.c
> @@ -285,6 +285,7 @@ int pdb_init_from_file(const char *name, struct pdb_reader *reader)
>      reader->gmf = g_mapped_file_new(name, TRUE, &gerr);
>      if (gerr) {
>          eprintf("Failed to map PDB file \'%s\'\n", name);
> +        g_error_free(gerr);
>          return 1;
>      }
>
> --
> 2.18.2
>
>