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

Re: [libvirt] [PATCH] security: avoid memory leak



On 02/21/2011 05:10 PM, Eric Blake wrote:
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;
  }


ACK.


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