qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] rdma: fix memory leak
@ 2015-06-23  1:02 arei.gonglei
  2015-06-23  4:12 ` Amit Shah
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: arei.gonglei @ 2015-06-23  1:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, amit.shah, Gonglei, mrhines, quintela

From: Gonglei <arei.gonglei@huawei.com>

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

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
---
 migration/rdma.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/migration/rdma.c b/migration/rdma.c
index cf5de7e..de80860 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 = NULL;
 
     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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-06-23  9:33 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-23  1:02 [Qemu-devel] [PATCH] rdma: fix memory leak arei.gonglei
2015-06-23  4:12 ` Amit Shah
2015-06-23  7:36 ` Markus Armbruster
2015-06-23  9:20   ` Markus Armbruster
2015-06-23  9:32     ` Gonglei
2015-06-23  7:47 ` Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).