[PATCH] security: avoid memory leak

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

 



Leak introduced in commit d6623003.

* src/qemu/qemu_driver.c (qemuSecurityInit): Avoid leak on failure.
* src/security/security_stack.c (virSecurityStackClose): Avoid
leaking component drivers.
---
 src/qemu/qemu_driver.c        |    5 ++++-
 src/security/security_stack.c |    7 ++++++-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 0f25a2a..8b15a3e 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -204,8 +204,11 @@ qemuSecurityInit(struct qemud_driver *driver)
             goto error;

         if (!(driver->securityManager = virSecurityManagerNewStack(mgr,
-                                                                   dac)))
+                                                                   dac))) {
+
+            virSecurityManagerFree(dac);
             goto error;
+        }
     } else {
         driver->securityManager = mgr;
     }
diff --git a/src/security/security_stack.c b/src/security/security_stack.c
index 79b3e1f..64f745a 100644
--- a/src/security/security_stack.c
+++ b/src/security/security_stack.c
@@ -61,8 +61,13 @@ virSecurityStackOpen(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED)
 }

 static int
-virSecurityStackClose(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED)
+virSecurityStackClose(virSecurityManagerPtr mgr)
 {
+    virSecurityStackDataPtr priv = virSecurityManagerGetPrivateData(mgr);
+
+    virSecurityManagerFree(priv->primary);
+    virSecurityManagerFree(priv->secondary);
+
     return 0;
 }

-- 
1.7.4

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