From: Gonglei Date: Tue, 23 Jun 2015 07:56:38 +0000 (+0800) Subject: rdma: fix memory leak X-Git-Tag: v2.4.0-rc0~15^2~27 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=728470bea15b11ba7b3e3db54f0d9939908e0e65;p=thirdparty%2Fqemu.git rdma: fix memory leak Variable "r" going out of scope leaks the storage it points to in line 3268. Signed-off-by: Gonglei Reviewed-by: Amit Shah Signed-off-by: Juan Quintela --- diff --git a/migration/rdma.c b/migration/rdma.c index b777273b596..0a00290160d 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -3263,12 +3263,13 @@ static const QEMUFileOps rdma_write_ops = { static void *qemu_fopen_rdma(RDMAContext *rdma, const char *mode) { - QEMUFileRDMA *r = g_malloc0(sizeof(QEMUFileRDMA)); + QEMUFileRDMA *r; if (qemu_file_mode_is_not_valid(mode)) { return NULL; } + r = g_malloc0(sizeof(QEMUFileRDMA)); r->rdma = rdma; if (mode[0] == 'w') {