From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49342) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZCScf-0004HV-EE for qemu-devel@nongnu.org; Tue, 07 Jul 2015 09:09:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZCScb-0003Ek-UA for qemu-devel@nongnu.org; Tue, 07 Jul 2015 09:09:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34127) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZCScb-0003Ee-PA for qemu-devel@nongnu.org; Tue, 07 Jul 2015 09:09:13 -0400 From: Juan Quintela Date: Tue, 7 Jul 2015 15:08:42 +0200 Message-Id: <1436274549-28826-2-git-send-email-quintela@redhat.com> In-Reply-To: <1436274549-28826-1-git-send-email-quintela@redhat.com> References: <1436274549-28826-1-git-send-email-quintela@redhat.com> Subject: [Qemu-devel] [PULL 01/28] rdma: fix memory leak List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: amit.shah@redhat.com, Gonglei From: Gonglei 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 --- migration/rdma.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/migration/rdma.c b/migration/rdma.c index b777273..0a00290 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') { -- 2.4.3