[PATCH 03/14] storage: Resolve resource leak using 'vol' buffer

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

 



---
 src/storage/storage_backend_rbd.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backend_rbd.c
index f5c6b0f..f916de1 100644
--- a/src/storage/storage_backend_rbd.c
+++ b/src/storage/storage_backend_rbd.c
@@ -329,16 +329,23 @@ static int virStorageBackendRBDRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED,
             goto out_of_memory;
 
         vol->name = strdup(name);
-        if (vol->name == NULL)
+        if (vol->name == NULL) {
+            VIR_FREE(vol);
             goto out_of_memory;
+        }
 
-        if (STREQ(vol->name, ""))
+        if (STREQ(vol->name, "")) {
+            VIR_FREE(vol->name);
+            VIR_FREE(vol);
             break;
+        }
 
         name += strlen(name) + 1;
 
-        if (volStorageBackendRBDRefreshVolInfo(vol, pool, ptr) < 0)
+        if (volStorageBackendRBDRefreshVolInfo(vol, pool, ptr) < 0) {
+            virStorageVolDefFree(vol);
             goto cleanup;
+        }
 
         pool->volumes.objs[pool->volumes.count++] = vol;
     }
-- 
1.7.11.7

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]