[PATCH] storage: fix unlikely memory leak in rbd backend

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

 



virStorageBackendRBDRefreshPool() first allocates an array big enough
to hold 1024 names, then calls rbd_list(), which returns ERANGE if the
array isn't big enough. When that happens, the VIR_ALLOC_N is called
again with a larger size. Unfortunately, the original array isn't
freed before allocating a new one.
---
 src/storage/storage_backend_rbd.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backend_rbd.c
index 8a0e517..e815192 100644
--- a/src/storage/storage_backend_rbd.c
+++ b/src/storage/storage_backend_rbd.c
@@ -317,6 +317,7 @@ static int virStorageBackendRBDRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED,
             VIR_WARN("%s", _("A problem occurred while listing RBD images"));
             goto cleanup;
         }
+        VIR_FREE(names);
     }
 
     for (i = 0, name = names; name < names + max_size; i++) {
-- 
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]