render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
Blob Blame History Raw
From 3b8e838edb8ca856d25dd2e0ce29d1082527d087 Mon Sep 17 00:00:00 2001
Message-Id: <3b8e838edb8ca856d25dd2e0ce29d1082527d087@dist-git>
From: Michal Privoznik <mprivozn@redhat.com>
Date: Mon, 25 Jul 2016 12:42:47 -0400
Subject: [PATCH] virStorageEncryptionSecretFree: Don't leak secret lookup
 definition

https://bugzilla.redhat.com/show_bug.cgi?id=1301021

When storage secret is parsed in virStorageEncryptionSecretParse(),
virSecretLookupParseSecret() which allocates some memory. This is
however never freed.

==21711== 134 bytes in 6 blocks are definitely lost in loss record 70 of 85
==21711==    at 0x4C29F80: malloc (vg_replace_malloc.c:296)
==21711==    by 0xBCA0356: xmlStrndup (in /usr/lib64/libxml2.so.2.9.4)
==21711==    by 0xA9F432E: virXMLPropString (virxml.c:479)
==21711==    by 0xA9D25B0: virSecretLookupParseSecret (virsecret.c:70)
==21711==    by 0xA9D616E: virStorageEncryptionSecretParse (virstorageencryption.c:172)
==21711==    by 0xA9D66B2: virStorageEncryptionParseXML (virstorageencryption.c:281)
==21711==    by 0xA9D68DF: virStorageEncryptionParseNode (virstorageencryption.c:338)
==21711==    by 0xAA12575: virDomainDiskDefParseXML (domain_conf.c:7606)
==21711==    by 0xAA2CAC6: virDomainDefParseXML (domain_conf.c:16658)
==21711==    by 0xAA2FC75: virDomainDefParseNode (domain_conf.c:17472)
==21711==    by 0xAA2FAE4: virDomainDefParse (domain_conf.c:17419)
==21711==    by 0xAA2FB72: virDomainDefParseFile (domain_conf.c:17443)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
(cherry picked from commit b04835258f3ea97c37f6a1aed370c6a2b29c58b2)
Signed-off-by: John Ferlan <jferlan@redhat.com>
---
 src/util/virstorageencryption.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/util/virstorageencryption.c b/src/util/virstorageencryption.c
index afb44da..cd17554 100644
--- a/src/util/virstorageencryption.c
+++ b/src/util/virstorageencryption.c
@@ -50,6 +50,7 @@ virStorageEncryptionSecretFree(virStorageEncryptionSecretPtr secret)
 {
     if (!secret)
         return;
+    virSecretLookupDefClear(&secret->seclookupdef);
     VIR_FREE(secret);
 }
 
-- 
2.9.2