diff mbox series

[RESEND,v2,3/7] elf2dmp/qemu_elf: Plug memleak in QEMU_Elf_init

Message ID 20201023061218.2080844-4-kuhn.chenqun@huawei.com
State New
Headers show
Series some memleak trivial patchs | expand

Commit Message

Chenqun (kuhn) Oct. 23, 2020, 6:12 a.m. UTC
From: Pan Nengyuan <pannengyuan@huawei.com>

Missing g_error_free in QEMU_Elf_init() error path. Fix that.

Reported-by: Euler Robot <euler.robot@huawei.com>
Signed-off-by: Pan Nengyuan <pannengyuan@huawei.com>
Reviewed-by: Viktor Prutyanov <viktor.prutyanov@phystech.edu>
Reviewed-by: Li Qiang <liq3ea@gmail.com>
Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com>
---
 contrib/elf2dmp/qemu_elf.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Thomas Huth Oct. 23, 2020, 7:22 a.m. UTC | #1
On 23/10/2020 08.12, Chen Qun wrote:
> From: Pan Nengyuan <pannengyuan@huawei.com>
> 
> Missing g_error_free in QEMU_Elf_init() error path. Fix that.
> 
> Reported-by: Euler Robot <euler.robot@huawei.com>
> Signed-off-by: Pan Nengyuan <pannengyuan@huawei.com>
> Reviewed-by: Viktor Prutyanov <viktor.prutyanov@phystech.edu>
> Reviewed-by: Li Qiang <liq3ea@gmail.com>
> Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com>
> ---
>  contrib/elf2dmp/qemu_elf.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/contrib/elf2dmp/qemu_elf.c b/contrib/elf2dmp/qemu_elf.c
> index 0db7816586..b601b6d7ba 100644
> --- a/contrib/elf2dmp/qemu_elf.c
> +++ b/contrib/elf2dmp/qemu_elf.c
> @@ -126,6 +126,7 @@ int QEMU_Elf_init(QEMU_Elf *qe, const char *filename)
>      qe->gmf = g_mapped_file_new(filename, TRUE, &gerr);
>      if (gerr) {
>          eprintf("Failed to map ELF dump file \'%s\'\n", filename);
> +        g_error_free(gerr);
>          return 1;
>      }
>  
> 

Reviewed-by: Thomas Huth <thuth@redhat.com>
Laurent Vivier Dec. 13, 2020, 5:44 p.m. UTC | #2
Le 23/10/2020 à 08:12, Chen Qun a écrit :
> From: Pan Nengyuan <pannengyuan@huawei.com>
> 
> Missing g_error_free in QEMU_Elf_init() error path. Fix that.
> 
> Reported-by: Euler Robot <euler.robot@huawei.com>
> Signed-off-by: Pan Nengyuan <pannengyuan@huawei.com>
> Reviewed-by: Viktor Prutyanov <viktor.prutyanov@phystech.edu>
> Reviewed-by: Li Qiang <liq3ea@gmail.com>
> Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com>
> ---
>  contrib/elf2dmp/qemu_elf.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/contrib/elf2dmp/qemu_elf.c b/contrib/elf2dmp/qemu_elf.c
> index 0db7816586..b601b6d7ba 100644
> --- a/contrib/elf2dmp/qemu_elf.c
> +++ b/contrib/elf2dmp/qemu_elf.c
> @@ -126,6 +126,7 @@ int QEMU_Elf_init(QEMU_Elf *qe, const char *filename)
>      qe->gmf = g_mapped_file_new(filename, TRUE, &gerr);
>      if (gerr) {
>          eprintf("Failed to map ELF dump file \'%s\'\n", filename);
> +        g_error_free(gerr);
>          return 1;
>      }
>  
> 

Applied to my trivial-patches branch.

Thanks,
Laurent
Chenqun (kuhn) Dec. 14, 2020, 2:26 a.m. UTC | #3
> -----Original Message-----
> From: Laurent Vivier [mailto:laurent@vivier.eu]
> Sent: Monday, December 14, 2020 1:44 AM
> To: Chenqun (kuhn) <kuhn.chenqun@huawei.com>; qemu-devel@nongnu.org;
> qemu-trivial@nongnu.org
> Cc: lvivier@redhat.com; Zhanghailiang <zhang.zhanghailiang@huawei.com>;
> Viktor Prutyanov <viktor.prutyanov@phystech.edu>; Li Qiang
> <liq3ea@gmail.com>; Pannengyuan <pannengyuan@huawei.com>; ganqixin
> <ganqixin@huawei.com>; Euler Robot <euler.robot@huawei.com>
> Subject: Re: [PATCH RESEND v2 3/7] elf2dmp/qemu_elf: Plug memleak in
> QEMU_Elf_init
> 
> Le 23/10/2020 à 08:12, Chen Qun a écrit :
> > From: Pan Nengyuan <pannengyuan@huawei.com>
> >
> > Missing g_error_free in QEMU_Elf_init() error path. Fix that.
> >
> > Reported-by: Euler Robot <euler.robot@huawei.com>
> > Signed-off-by: Pan Nengyuan <pannengyuan@huawei.com>
> > Reviewed-by: Viktor Prutyanov <viktor.prutyanov@phystech.edu>
> > Reviewed-by: Li Qiang <liq3ea@gmail.com>
> > Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com>
> > ---
> >  contrib/elf2dmp/qemu_elf.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/contrib/elf2dmp/qemu_elf.c b/contrib/elf2dmp/qemu_elf.c
> > index 0db7816586..b601b6d7ba 100644
> > --- a/contrib/elf2dmp/qemu_elf.c
> > +++ b/contrib/elf2dmp/qemu_elf.c
> > @@ -126,6 +126,7 @@ int QEMU_Elf_init(QEMU_Elf *qe, const char
> *filename)
> >      qe->gmf = g_mapped_file_new(filename, TRUE, &gerr);
> >      if (gerr) {
> >          eprintf("Failed to map ELF dump file \'%s\'\n", filename);
> > +        g_error_free(gerr);
> >          return 1;
> >      }
> >
> >
> 
> Applied to my trivial-patches branch.
> 
Hi Laurent,
  Thank you for picked them up!
But, there are two patches that have not been picked up.
Maybe I should ping the corresponding Maintainer first.

The missing patches are:
[PATCH RESEND v2 2/7] qga/channel-posix: Plug memory leak in ga_channel_write_all()
[PATCH RESEND v2 5/7] migration/colo: Plug memleaks in colo_process_incoming_thread

Thanks,
Chen Qun
diff mbox series

Patch

diff --git a/contrib/elf2dmp/qemu_elf.c b/contrib/elf2dmp/qemu_elf.c
index 0db7816586..b601b6d7ba 100644
--- a/contrib/elf2dmp/qemu_elf.c
+++ b/contrib/elf2dmp/qemu_elf.c
@@ -126,6 +126,7 @@  int QEMU_Elf_init(QEMU_Elf *qe, const char *filename)
     qe->gmf = g_mapped_file_new(filename, TRUE, &gerr);
     if (gerr) {
         eprintf("Failed to map ELF dump file \'%s\'\n", filename);
+        g_error_free(gerr);
         return 1;
     }