[PATCH v14 01/49] virscsi: fix memory leak

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

 



Signed-off-by: Chunyan Liu <cyliu@xxxxxxxx>
---
 src/util/virscsi.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/src/util/virscsi.c b/src/util/virscsi.c
index 69eae24..627b3f8 100644
--- a/src/util/virscsi.c
+++ b/src/util/virscsi.c
@@ -296,12 +296,17 @@ virSCSIDeviceSetUsedBy(virSCSIDevicePtr dev,
     virUsedByInfoPtr copy;
     if (VIR_ALLOC(copy) < 0)
         return -1;
-    if (VIR_STRDUP(copy->drvname, drvname) < 0)
-        return -1;
-    if (VIR_STRDUP(copy->domname, domname) < 0)
-        return -1;
+    if (VIR_STRDUP(copy->drvname, drvname) < 0 ||
+        VIR_STRDUP(copy->domname, domname) < 0)
+        goto cleanup;
 
     return VIR_APPEND_ELEMENT(dev->used_by, dev->n_used_by, copy);
+
+cleanup:
+    VIR_FREE(copy->drvname);
+    VIR_FREE(copy->domname);
+    VIR_FREE(copy);
+    return -1;
 }
 
 bool
-- 
1.9.0

--
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]