render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
8c03ec
From 4792bd80c542f7af373bc939492017bd420a3f3b Mon Sep 17 00:00:00 2001
8c03ec
Message-Id: <4792bd80c542f7af373bc939492017bd420a3f3b@dist-git>
8c03ec
From: Laine Stump <laine@redhat.com>
8c03ec
Date: Wed, 14 Apr 2021 23:25:33 -0400
8c03ec
Subject: [PATCH] network: make it safe to call networkSetupPrivateChains()
8c03ec
 multiple times
8c03ec
MIME-Version: 1.0
8c03ec
Content-Type: text/plain; charset=UTF-8
8c03ec
Content-Transfer-Encoding: 8bit
8c03ec
8c03ec
networkSetupPrivateChains() is currently called only once per run of
8c03ec
libvirtd, so it can assume that errInitV4 and errInitV6 are empty/null
8c03ec
when it is called. In preparation for potentially calling this
8c03ec
function multiple times during one run, this patch moves the reset of
8c03ec
errInitV[46] to the top of the function, to assure no memory is
8c03ec
leaked.
8c03ec
8c03ec
Signed-off-by: Laine Stump <laine@redhat.com>
8c03ec
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
8c03ec
(cherry picked from commit de110f110fb917a31b9f33ad8e4b3c1d3284766a)
8c03ec
8c03ec
https://bugzilla.redhat.com/1942805
8c03ec
8c03ec
Message-Id: <20210415032534.723202-2-laine@redhat.com>
8c03ec
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
8c03ec
---
8c03ec
 src/network/bridge_driver_linux.c | 8 ++++----
8c03ec
 1 file changed, 4 insertions(+), 4 deletions(-)
8c03ec
8c03ec
diff --git a/src/network/bridge_driver_linux.c b/src/network/bridge_driver_linux.c
8c03ec
index 9de8e93c60..b6b324d1d5 100644
8c03ec
--- a/src/network/bridge_driver_linux.c
8c03ec
+++ b/src/network/bridge_driver_linux.c
8c03ec
@@ -48,6 +48,10 @@ static void networkSetupPrivateChains(void)
8c03ec
     VIR_DEBUG("Setting up global firewall chains");
8c03ec
 
8c03ec
     createdChains = false;
8c03ec
+    virFreeError(errInitV4);
8c03ec
+    errInitV4 = NULL;
8c03ec
+    virFreeError(errInitV6);
8c03ec
+    errInitV6 = NULL;
8c03ec
 
8c03ec
     rc = iptablesSetupPrivateChains(VIR_FIREWALL_LAYER_IPV4);
8c03ec
     if (rc < 0) {
8c03ec
@@ -56,8 +60,6 @@ static void networkSetupPrivateChains(void)
8c03ec
         errInitV4 = virSaveLastError();
8c03ec
         virResetLastError();
8c03ec
     } else {
8c03ec
-        virFreeError(errInitV4);
8c03ec
-        errInitV4 = NULL;
8c03ec
         if (rc) {
8c03ec
             VIR_DEBUG("Created global IPv4 chains");
8c03ec
             createdChains = true;
8c03ec
@@ -73,8 +75,6 @@ static void networkSetupPrivateChains(void)
8c03ec
         errInitV6 = virSaveLastError();
8c03ec
         virResetLastError();
8c03ec
     } else {
8c03ec
-        virFreeError(errInitV6);
8c03ec
-        errInitV6 = NULL;
8c03ec
         if (rc) {
8c03ec
             VIR_DEBUG("Created global IPv6 chains");
8c03ec
             createdChains = true;
8c03ec
-- 
8c03ec
2.31.1
8c03ec