]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
storage: fix unlikely memory leak in rbd backend
authorLaine Stump <laine@laine.org>
Mon, 18 Mar 2013 20:04:11 +0000 (16:04 -0400)
committerLaine Stump <laine@laine.org>
Tue, 19 Mar 2013 16:10:42 +0000 (12:10 -0400)
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

index 8a0e517502c482f23f01bc63e95f1dc210d711cd..e815192c22a014cbe85ee197b01219b3deb95b21 100644 (file)
@@ -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++) {