migration/rdma: fix nullptr-def in rdma_start_incoming_migration
cover migration/rdma: fix nullptr-def in rdma_start_incoming_migration
I fix a memleak in rdma_start_incoming_migration some time ago.
https://patchwork.kernel.org/patch/11498191/
I'm sorry that it may cause a null-pointer access, this patch fix that.
Since we are here, rdma_start_outgoing_migration has the similar memleak, fix it together.
Pan Nengyuan (2):
migration/rdma: fix potential nullptr access in
rdma_start_incoming_migration
migration/rdma: cleanup rdma context before g_free to avoid memleaks
migration/rdma.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
Signature · 1 line
2.18.2
PATCH 1/2 migration/rdma: fix potential nullptr access in rdma_start_incoming_migration
'rdma' is NULL when taking the first error branch in rdma_start_incoming_migration. And it will cause a null pointer access in label 'err'. Fix that.
--- migration/rdma.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
migration/rdma.c +3 -1
@@ -4056,7 +4056,9 @@ void rdma_start_incoming_migration(const char *host_port, Error **errp)return ; err:error_propagate (errp, local_err); -g_free (rdma->host); +if (rdma) { +g_free (rdma->host); + }g_free (rdma);g_free (rdma_return_path); }
Signature · 1 line
2.18.2
Re: [PATCH 1/2] migration/rdma: fix potential nullptr access in rdma_start_incoming_migration
Quoted 5 lines · Pan Nengyuan
'rdma' is NULL when taking the first error branch in
rdma_start_incoming_migration. And it will cause a null pointer access in label 'err'. Fix that.Fixes 59c59c67ee6b0327ae932deb303caa47919aeb1eSigned-off-by Pan Nengyuan <[email protected]>
good catch.
Re: [PATCH 1/2] migration/rdma: fix potential nullptr access in rdma_start_incoming_migration
Quoted 9 lines · Juan Quintela
Quoted 5 lines · Pan Nengyuan
'rdma' is NULL when taking the first error branch in
rdma_start_incoming_migration. And it will cause a null pointer access in label 'err'. Fix that.Fixes 59c59c67ee6b0327ae932deb303caa47919aeb1eSigned-off-by Pan Nengyuan <[email protected]>Reviewed-by Juan Quintela <[email protected]>
NB: this is CID 1428762.
thanks
-- PMM
Re: [PATCH 1/2] migration/rdma: fix potential nullptr access in rdma_start_incoming_migration
In reply to Juan QuintelaQuoted 10 lines · * Juan Quintela ([email protected]) wrote:
Quoted 5 lines · Pan Nengyuan
'rdma' is NULL when taking the first error branch in
rdma_start_incoming_migration. And it will cause a null pointer access in label 'err'. Fix that.Fixes 59c59c67ee6b0327ae932deb303caa47919aeb1eSigned-off-by Pan Nengyuan <[email protected]>Reviewed-by Juan Quintela <[email protected]>good catch.
Thanks, Queued
Quoted 1 line
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
PATCH 2/2 migration/rdma: cleanup rdma context before g_free to avoid memleaks
In reply to Pan NengyuanWhen error happen in initializing 'rdma_return_path', we should cleanup rdma context before g_free(rdma) to avoid some memleaks. This patch fix that.
--- migration/rdma.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
migration/rdma.c +5 -3
@@ -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);
Signature · 1 line
2.18.2
Re: [PATCH 2/2] migration/rdma: cleanup rdma context before g_free to avoid memleaks
Quoted 5 lines · Pan Nengyuan
When error happen in initializing '
rdma_return_path', we should cleanup rdma context beforeg_free(rdma)to avoid some memleaks. This patch fix that.Reported-by Euler Robot <[email protected]>Signed-off-by Pan Nengyuan <[email protected]>
Another good catch.
Re: [PATCH 2/2] migration/rdma: cleanup rdma context before g_free to avoid memleaks
In reply to Pan NengyuanQuoted 5 lines · * Pan Nengyuan ([email protected]) wrote:
When error happen in initializing '
rdma_return_path', we should cleanup rdma context beforeg_free(rdma)to avoid some memleaks. This patch fix that.Reported-by Euler Robot <[email protected]>Signed-off-by Pan Nengyuan <[email protected]>
Queued.
Quoted 44 lines
--- migration/rdma.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)migration/rdma.c +5
-3@@ -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);Signature · 1 line
2.18.2
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK