From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59097) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZAh49-0004mJ-QI for qemu-devel@nongnu.org; Thu, 02 Jul 2015 12:10:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZAh47-0005Z1-Kp for qemu-devel@nongnu.org; Thu, 02 Jul 2015 12:10:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46135) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZAh47-0005Yt-Fc for qemu-devel@nongnu.org; Thu, 02 Jul 2015 12:10:19 -0400 From: Juan Quintela Date: Thu, 2 Jul 2015 18:09:49 +0200 Message-Id: <1435853415-23545-2-git-send-email-quintela@redhat.com> In-Reply-To: <1435853415-23545-1-git-send-email-quintela@redhat.com> References: <1435853415-23545-1-git-send-email-quintela@redhat.com> Subject: [Qemu-devel] [PULL 01/27] 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