qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH 1/3] rbd: fix leak in failure path


From: Sage Weil
Subject: [Qemu-devel] [PATCH 1/3] rbd: fix leak in failure path
Date: Tue, 23 Aug 2011 09:28:30 -0700

Fix leak of s->snap when rados_create fails.

Reported-by: Stefan Hajnoczi <address@hidden>
Signed-off-by: Sage Weil <address@hidden>
---
 block/rbd.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/block/rbd.c b/block/rbd.c
index d5659cd..52b79fa 100644
--- a/block/rbd.c
+++ b/block/rbd.c
@@ -393,10 +393,6 @@ static int qemu_rbd_open(BlockDriverState *bs, const char 
*filename, int flags)
                            conf, sizeof(conf)) < 0) {
         return -EINVAL;
     }
-    s->snap = NULL;
-    if (snap_buf[0] != '\0') {
-        s->snap = qemu_strdup(snap_buf);
-    }
 
     r = rados_create(&s->cluster, NULL);
     if (r < 0) {
@@ -404,6 +400,11 @@ static int qemu_rbd_open(BlockDriverState *bs, const char 
*filename, int flags)
         return r;
     }
 
+    s->snap = NULL;
+    if (snap_buf[0] != '\0') {
+        s->snap = qemu_strdup(snap_buf);
+    }
+
     if (strstr(conf, "conf=") == NULL) {
         r = rados_conf_read_file(s->cluster, NULL);
         if (r < 0) {
-- 
1.7.0




reply via email to

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