[PATCH] virStorageSourceClear: Unref @vhostuser

Michal Privoznik posted 1 patch 3 years, 2 months ago
Test syntax-check failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/61713c91d7d03ab29d73eb83517f55118304af68.1612950763.git.mprivozn@redhat.com
src/conf/storage_source_conf.c | 1 +
1 file changed, 1 insertion(+)
[PATCH] virStorageSourceClear: Unref @vhostuser
Posted by Michal Privoznik 3 years, 2 months ago
The @vhostuser member of virStorageSource structure is allocated
during parsing in virDomainDiskSourceVHostUserParse() but never
freed leading to a memleak. Since the member is an object it has
to be unrefed instead of g_free()-d.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 src/conf/storage_source_conf.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/conf/storage_source_conf.c b/src/conf/storage_source_conf.c
index 7706bbd8da..67c3aedefb 100644
--- a/src/conf/storage_source_conf.c
+++ b/src/conf/storage_source_conf.c
@@ -1125,6 +1125,7 @@ virStorageSourceClear(virStorageSourcePtr def)
     virStorageEncryptionFree(def->encryption);
     virStoragePRDefFree(def->pr);
     virStorageSourceNVMeDefFree(def->nvme);
+    virObjectUnref(def->vhostuser);
     virStorageSourceSeclabelsClear(def);
     virStoragePermsFree(def->perms);
     VIR_FREE(def->timestamps);
-- 
2.26.2

Re: [PATCH] virStorageSourceClear: Unref @vhostuser
Posted by Pavel Hrdina 3 years, 2 months ago
On Wed, Feb 10, 2021 at 10:52:43AM +0100, Michal Privoznik wrote:
> The @vhostuser member of virStorageSource structure is allocated
> during parsing in virDomainDiskSourceVHostUserParse() but never
> freed leading to a memleak. Since the member is an object it has
> to be unrefed instead of g_free()-d.
> 
> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
> ---
>  src/conf/storage_source_conf.c | 1 +
>  1 file changed, 1 insertion(+)

Oops, thanks for fixing it.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>