mirror of https://github.com/xemu-project/xemu.git
migration/rdma: cleanup rdma context before g_free to avoid memleaks
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 <euler.robot@huawei.com> Signed-off-by: Pan Nengyuan <pannengyuan@huawei.com> Message-Id: <20200508100755.7875-3-pannengyuan@huawei.com> Reviewed-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
This commit is contained in:
parent
3b59ee7227
commit
2f0c285aaa
|
@ -4094,20 +4094,20 @@ void rdma_start_outgoing_migration(void *opaque,
|
||||||
rdma_return_path = qemu_rdma_data_init(host_port, errp);
|
rdma_return_path = qemu_rdma_data_init(host_port, errp);
|
||||||
|
|
||||||
if (rdma_return_path == NULL) {
|
if (rdma_return_path == NULL) {
|
||||||
goto err;
|
goto return_path_err;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = qemu_rdma_source_init(rdma_return_path,
|
ret = qemu_rdma_source_init(rdma_return_path,
|
||||||
s->enabled_capabilities[MIGRATION_CAPABILITY_RDMA_PIN_ALL], errp);
|
s->enabled_capabilities[MIGRATION_CAPABILITY_RDMA_PIN_ALL], errp);
|
||||||
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
goto err;
|
goto return_path_err;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = qemu_rdma_connect(rdma_return_path, errp);
|
ret = qemu_rdma_connect(rdma_return_path, errp);
|
||||||
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
goto err;
|
goto return_path_err;
|
||||||
}
|
}
|
||||||
|
|
||||||
rdma->return_path = rdma_return_path;
|
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");
|
s->to_dst_file = qemu_fopen_rdma(rdma, "wb");
|
||||||
migrate_fd_connect(s, NULL);
|
migrate_fd_connect(s, NULL);
|
||||||
return;
|
return;
|
||||||
|
return_path_err:
|
||||||
|
qemu_rdma_cleanup(rdma);
|
||||||
err:
|
err:
|
||||||
g_free(rdma);
|
g_free(rdma);
|
||||||
g_free(rdma_return_path);
|
g_free(rdma_return_path);
|
||||||
|
|
Loading…
Reference in New Issue