render / rpms / libvirt

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