Re: [PATCH 2/2] migration/rdma: cleanup rdma context before g_free to avoid memleaks

2020-05-29 Thread Dr. David Alan Gilbert
* Pan Nengyuan (pannengy...@huawei.com) wrote:
> When error happen in initializing 'rdma_return_path', we should cleanup rdma 
> context
> before g_free(rdma) to avoid some memleaks. This patch fix that.
> 
> Reported-by: Euler Robot 
> Signed-off-by: Pan Nengyuan 

Queued.

> ---
>  migration/rdma.c | 8 +---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/migration/rdma.c b/migration/rdma.c
> index 72e8b1c95b..ec45d33ba3 100644
> --- a/migration/rdma.c
> +++ b/migration/rdma.c
> @@ -4094,20 +4094,20 @@ void rdma_start_outgoing_migration(void *opaque,
>  rdma_return_path = qemu_rdma_data_init(host_port, errp);
>  
>  if (rdma_return_path == NULL) {
> -goto err;
> +goto return_path_err;
>  }
>  
>  ret = qemu_rdma_source_init(rdma_return_path,
>  s->enabled_capabilities[MIGRATION_CAPABILITY_RDMA_PIN_ALL], 
> errp);
>  
>  if (ret) {
> -goto err;
> +goto return_path_err;
>  }
>  
>  ret = qemu_rdma_connect(rdma_return_path, errp);
>  
>  if (ret) {
> -goto err;
> +goto return_path_err;
>  }
>  
>  rdma->return_path = rdma_return_path;
> @@ -4120,6 +4120,8 @@ void rdma_start_outgoing_migration(void *opaque,
>  s->to_dst_file = qemu_fopen_rdma(rdma, "wb");
>  migrate_fd_connect(s, NULL);
>  return;
> +return_path_err:
> +qemu_rdma_cleanup(rdma);
>  err:
>  g_free(rdma);
>  g_free(rdma_return_path);
> -- 
> 2.18.2
> 
--
Dr. David Alan Gilbert / dgilb...@redhat.com / Manchester, UK




Re: [PATCH 2/2] migration/rdma: cleanup rdma context before g_free to avoid memleaks

2020-05-08 Thread Juan Quintela
Pan Nengyuan  wrote:
> When error happen in initializing 'rdma_return_path', we should cleanup rdma 
> context
> before g_free(rdma) to avoid some memleaks. This patch fix that.
>
> Reported-by: Euler Robot 
> Signed-off-by: Pan Nengyuan 

Reviewed-by: Juan Quintela 

Another good catch.




[PATCH 2/2] migration/rdma: cleanup rdma context before g_free to avoid memleaks

2020-05-07 Thread Pan Nengyuan
When error happen in initializing 'rdma_return_path', we should cleanup rdma 
context
before g_free(rdma) to avoid some memleaks. This patch fix that.

Reported-by: Euler Robot 
Signed-off-by: Pan Nengyuan 
---
 migration/rdma.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/migration/rdma.c b/migration/rdma.c
index 72e8b1c95b..ec45d33ba3 100644
--- a/migration/rdma.c
+++ b/migration/rdma.c
@@ -4094,20 +4094,20 @@ void rdma_start_outgoing_migration(void *opaque,
 rdma_return_path = qemu_rdma_data_init(host_port, errp);
 
 if (rdma_return_path == NULL) {
-goto err;
+goto return_path_err;
 }
 
 ret = qemu_rdma_source_init(rdma_return_path,
 s->enabled_capabilities[MIGRATION_CAPABILITY_RDMA_PIN_ALL], errp);
 
 if (ret) {
-goto err;
+goto return_path_err;
 }
 
 ret = qemu_rdma_connect(rdma_return_path, errp);
 
 if (ret) {
-goto err;
+goto return_path_err;
 }
 
 rdma->return_path = rdma_return_path;
@@ -4120,6 +4120,8 @@ void rdma_start_outgoing_migration(void *opaque,
 s->to_dst_file = qemu_fopen_rdma(rdma, "wb");
 migrate_fd_connect(s, NULL);
 return;
+return_path_err:
+qemu_rdma_cleanup(rdma);
 err:
 g_free(rdma);
 g_free(rdma_return_path);
-- 
2.18.2