Blame SOURCES/libvirt-network-make-it-safe-to-call-networkSetupPrivateChains-multiple-times.patch

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