Skip to content

Commit 9cde9ca

Browse files
author
Markus Armbruster
committed
migration/rdma: Plug memory leaks in qemu_rdma_registration_stop()
qemu_rdma_registration_stop() uses the ERROR() macro to create, report to stderr, and store an Error object. The stored Error object is never used, and its memory is leaked. Even where ERROR() doesn't leak, it is ill-advised. The whole point of passing an Error to the caller is letting the caller handle the error. Error handling may report to stderr, to somewhere else, or not at all. Also reporting in the callee mixes up concerns that should be kept separate. Since I don't know what reporting to stderr is supposed to accomplish, I'm not touching it. Commit 2a1bc8b "migration/rdma: rdma_accept_incoming_migration fix error handling" plugged the same leak in rdma_accept_incoming_migration(). Plug the memory leak the same way: keep the report part, delete the store part. The report part uses fprintf(). If it's truly an error, it should use error_report() instead. But I don't know, so I leave it alone, just like commit 2a1bc8b did. Fixes: 2da776d Cc: Dr. David Alan Gilbert <[email protected]> Cc: Juan Quintela <[email protected]> Signed-off-by: Markus Armbruster <[email protected]> Message-Id: <[email protected]> Reviewed-by: Dr. David Alan Gilbert <[email protected]>
1 parent 7cd1c98 commit 9cde9ca

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

migration/rdma.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3787,7 +3787,6 @@ static int qemu_rdma_registration_start(QEMUFile *f, void *opaque,
37873787
static int qemu_rdma_registration_stop(QEMUFile *f, void *opaque,
37883788
uint64_t flags, void *data)
37893789
{
3790-
Error *local_err = NULL, **errp = &local_err;
37913790
QIOChannelRDMA *rioc = QIO_CHANNEL_RDMA(opaque);
37923791
RDMAContext *rdma;
37933792
RDMAControlHeader head = { .len = 0, .repeat = 1 };
@@ -3832,7 +3831,7 @@ static int qemu_rdma_registration_stop(QEMUFile *f, void *opaque,
38323831
&reg_result_idx, rdma->pin_all ?
38333832
qemu_rdma_reg_whole_ram_blocks : NULL);
38343833
if (ret < 0) {
3835-
ERROR(errp, "receiving remote info!");
3834+
fprintf(stderr, "receiving remote info!");
38363835
return ret;
38373836
}
38383837

@@ -3851,10 +3850,10 @@ static int qemu_rdma_registration_stop(QEMUFile *f, void *opaque,
38513850
*/
38523851

38533852
if (local->nb_blocks != nb_dest_blocks) {
3854-
ERROR(errp, "ram blocks mismatch (Number of blocks %d vs %d) "
3855-
"Your QEMU command line parameters are probably "
3856-
"not identical on both the source and destination.",
3857-
local->nb_blocks, nb_dest_blocks);
3853+
fprintf(stderr, "ram blocks mismatch (Number of blocks %d vs %d) "
3854+
"Your QEMU command line parameters are probably "
3855+
"not identical on both the source and destination.",
3856+
local->nb_blocks, nb_dest_blocks);
38583857
rdma->error_state = -EINVAL;
38593858
return -EINVAL;
38603859
}
@@ -3867,10 +3866,10 @@ static int qemu_rdma_registration_stop(QEMUFile *f, void *opaque,
38673866

38683867
/* We require that the blocks are in the same order */
38693868
if (rdma->dest_blocks[i].length != local->block[i].length) {
3870-
ERROR(errp, "Block %s/%d has a different length %" PRIu64
3871-
"vs %" PRIu64, local->block[i].block_name, i,
3872-
local->block[i].length,
3873-
rdma->dest_blocks[i].length);
3869+
fprintf(stderr, "Block %s/%d has a different length %" PRIu64
3870+
"vs %" PRIu64, local->block[i].block_name, i,
3871+
local->block[i].length,
3872+
rdma->dest_blocks[i].length);
38743873
rdma->error_state = -EINVAL;
38753874
return -EINVAL;
38763875
}

0 commit comments

Comments
 (0)