qemu-trivial
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-trivial] [PATCH v2] rdma: fix memory leak


From: arei.gonglei
Subject: [Qemu-trivial] [PATCH v2] rdma: fix memory leak
Date: Tue, 23 Jun 2015 15:56:38 +0800

From: Gonglei <address@hidden>

Variable "r" going out of scope leaks the storage
it points to in line 3268.

Signed-off-by: Gonglei <address@hidden>
Reviewed-by: Amit Shah <address@hidden>
---
 v2:
  - Drop needless initialization. (Markus & Paolo)
  - add Amit's R-by.
---
 migration/rdma.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/migration/rdma.c b/migration/rdma.c
index cf5de7e..b5f9f82 100644
--- a/migration/rdma.c
+++ b/migration/rdma.c
@@ -3262,12 +3262,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') {
-- 
1.7.12.4





reply via email to

[Prev in Thread] Current Thread [Next in Thread]