[PATCH v2 07/10] migration/colo: Plug memleaks in colo_process_incoming_thread

Pan Nengyuan posted 10 patches 5 years, 5 months ago
Maintainers: Hailiang Zhang <zhang.zhanghailiang@huawei.com>, Markus Armbruster <armbru@redhat.com>, "Dr. David Alan Gilbert" <dgilbert@redhat.com>, Juan Quintela <quintela@redhat.com>, Michael Roth <mdroth@linux.vnet.ibm.com>, Gerd Hoffmann <kraxel@redhat.com>, Max Reitz <mreitz@redhat.com>, Richard Henderson <rth@twiddle.net>, Eduardo Habkost <ehabkost@redhat.com>, Kevin Wolf <kwolf@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, Viktor Prutyanov <viktor.prutyanov@phystech.edu>
[PATCH v2 07/10] migration/colo: Plug memleaks in colo_process_incoming_thread
Posted by Pan Nengyuan 5 years, 5 months ago
'local_err' forgot to free in colo_process_incoming_thread error path.
Fix that.

Reported-by: Euler Robot <euler.robot@huawei.com>
Signed-off-by: Pan Nengyuan <pannengyuan@huawei.com>
---
Cc: Hailiang Zhang <zhang.zhanghailiang@huawei.com>
Cc: Juan Quintela <quintela@redhat.com>
Cc: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
---
- V2: Arrange all 'error_report_err' in 'out' label(suggested by Li Qiang).
---
 migration/colo.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/migration/colo.c b/migration/colo.c
index ea7d1e9d4e..2288188fe2 100644
--- a/migration/colo.c
+++ b/migration/colo.c
@@ -888,7 +888,6 @@ void *colo_process_incoming_thread(void *opaque)
     while (mis->state == MIGRATION_STATUS_COLO) {
         colo_wait_handle_message(mis, fb, bioc, &local_err);
         if (local_err) {
-            error_report_err(local_err);
             break;
         }
 
@@ -924,6 +923,10 @@ out:
         qemu_fclose(fb);
     }
 
+    if (local_err) {
+        error_report_err(local_err);
+    }
+
     /* Hope this not to be too long to loop here */
     qemu_sem_wait(&mis->colo_incoming_sem);
     qemu_sem_destroy(&mis->colo_incoming_sem);
-- 
2.18.2


Re: [PATCH v2 07/10] migration/colo: Plug memleaks in colo_process_incoming_thread
Posted by Li Qiang 5 years, 5 months ago
Pan Nengyuan <pannengyuan@huawei.com> 于2020年8月31日周一 下午3:17写道:
>
> 'local_err' forgot to free in colo_process_incoming_thread 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: Hailiang Zhang <zhang.zhanghailiang@huawei.com>
> Cc: Juan Quintela <quintela@redhat.com>
> Cc: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
> ---
> - V2: Arrange all 'error_report_err' in 'out' label(suggested by Li Qiang).
> ---
>  migration/colo.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/migration/colo.c b/migration/colo.c
> index ea7d1e9d4e..2288188fe2 100644
> --- a/migration/colo.c
> +++ b/migration/colo.c
> @@ -888,7 +888,6 @@ void *colo_process_incoming_thread(void *opaque)
>      while (mis->state == MIGRATION_STATUS_COLO) {
>          colo_wait_handle_message(mis, fb, bioc, &local_err);
>          if (local_err) {
> -            error_report_err(local_err);
>              break;
>          }
>
> @@ -924,6 +923,10 @@ out:
>          qemu_fclose(fb);
>      }
>
> +    if (local_err) {
> +        error_report_err(local_err);
> +    }
> +
>      /* Hope this not to be too long to loop here */
>      qemu_sem_wait(&mis->colo_incoming_sem);
>      qemu_sem_destroy(&mis->colo_incoming_sem);
> --
> 2.18.2
>
>