OSDN Git Service

rdma: fix memory leak
authorGonglei <arei.gonglei@huawei.com>
Tue, 23 Jun 2015 07:56:38 +0000 (15:56 +0800)
committerJuan Quintela <quintela@redhat.com>
Tue, 7 Jul 2015 12:54:46 +0000 (14:54 +0200)
Variable "r" going out of scope leaks the storage
it points to in line 3268.

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Reviewed-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
migration/rdma.c

index b777273..0a00290 100644 (file)
@@ -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') {