[libvirt] [PATCH 11/20] phyp: Remove the last instance of stack allocating a 4kb volume key

Matthias Bolte matthias.bolte at googlemail.com
Sun Apr 3 09:21:24 UTC 2011


---
 src/phyp/phyp_driver.c |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c
index fe2e99d..76207c2 100644
--- a/src/phyp/phyp_driver.c
+++ b/src/phyp/phyp_driver.c
@@ -2362,13 +2362,22 @@ phypBuildVolume(virConnectPtr conn, const char *lvname, const char *spname,
 static virStorageVolPtr
 phypVolumeLookupByName(virStoragePoolPtr pool, const char *volname)
 {
+    char *key;
+    virStorageVolPtr vol;
 
-    char key[MAX_KEY_SIZE];
+    if (VIR_ALLOC_N(key, MAX_KEY_SIZE) < 0) {
+        virReportOOMError();
+        return NULL;
+    }
 
     if (phypVolumeGetKey(pool->conn, key, volname) == -1)
         return NULL;
 
-    return virGetStorageVol(pool->conn, pool->name, volname, key);
+    vol = virGetStorageVol(pool->conn, pool->name, volname, key);
+
+    VIR_FREE(key);
+
+    return vol;
 }
 
 static virStorageVolPtr
-- 
1.7.0.4




More information about the libvir-list mailing list