2cf05b
From 0f6009e5a8ca63388772597f3e42c71b50635a02 Mon Sep 17 00:00:00 2001
2cf05b
Message-Id: <0f6009e5a8ca63388772597f3e42c71b50635a02@dist-git>
2cf05b
From: Peng Liang <liangpeng10@huawei.com>
2cf05b
Date: Wed, 2 Mar 2022 17:22:05 +0800
2cf05b
Subject: [PATCH] rpc: Fix memory leak of fds
2cf05b
2cf05b
In virSystemdActivationClaimFDs, the memory of ent->fds has been stolen
2cf05b
and stored in fds, but fds is never freed, which causes a memory leak.
2cf05b
Fix it by declaring fds as g_autofree.
2cf05b
2cf05b
Reported-by: Jie Tang <tangjie18@huawei.com>
2cf05b
Signed-off-by: Peng Liang <liangpeng10@huawei.com>
2cf05b
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2cf05b
(cherry picked from commit 8a1915c4d6c33669dcb390d0708cb6e5d651770d)
2cf05b
https://bugzilla.redhat.com/show_bug.cgi?id=2165428
2cf05b
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2cf05b
---
2cf05b
 src/rpc/virnetserver.c | 2 +-
2cf05b
 1 file changed, 1 insertion(+), 1 deletion(-)
2cf05b
2cf05b
diff --git a/src/rpc/virnetserver.c b/src/rpc/virnetserver.c
2cf05b
index ad581a36dd..d9430a2cfa 100644
2cf05b
--- a/src/rpc/virnetserver.c
2cf05b
+++ b/src/rpc/virnetserver.c
2cf05b
@@ -655,7 +655,7 @@ virNetServerAddServiceActivation(virNetServer *srv,
2cf05b
                                  size_t max_queued_clients,
2cf05b
                                  size_t nrequests_client_max)
2cf05b
 {
2cf05b
-    int *fds;
2cf05b
+    g_autofree int *fds = NULL;
2cf05b
     size_t nfds;
2cf05b
 
2cf05b
     if (act == NULL)
2cf05b
-- 
2cf05b
2.39.1
2cf05b