aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJakub Ružička <jakub.ruzicka@nic.cz>2023-02-20 18:12:14 +0100
committerJakub Ružička <jakub.ruzicka@nic.cz>2023-02-20 18:12:14 +0100
commitdc679bfa2d1a4b882f4814fe510fb0a400c924ef (patch)
treed2a0f8a48a4c5cef63d1997b2cfdf2bbe2dacc65
parent4f42c9aabcace7ab63d87bd1a257877f7121bfd5 (diff)
downloadbird-dc679bfa2d1a4b882f4814fe510fb0a400c924ef.tar.gz
Add upstream patch to fix early free in config
Upstream Patch: https://gitlab.nic.cz/labs/bird/-/commit/eefb29679957
-rw-r--r--debian/patches/0002-Conf-Fix-too-early-free.patch53
-rw-r--r--debian/patches/series1
2 files changed, 54 insertions, 0 deletions
diff --git a/debian/patches/0002-Conf-Fix-too-early-free.patch b/debian/patches/0002-Conf-Fix-too-early-free.patch
new file mode 100644
index 00000000..4012798a
--- /dev/null
+++ b/debian/patches/0002-Conf-Fix-too-early-free.patch
@@ -0,0 +1,53 @@
+From eefb29679957fed3724e6d5db2ddf112e28f646f Mon Sep 17 00:00:00 2001
+From: Ondrej Zajicek <santiago@crfreenet.org>
+Date: Sun, 19 Feb 2023 03:59:10 +0100
+Subject: [PATCH] Conf: Fix too early free of old configuration
+
+The change 371eb49043d225d2bab8149187b813a14b4b86d2 introduced early free
+of old_config. Unfortunately, it did not properly check whether it is not
+still in use (blocked by obstacle during reconfiguration). Fix that.
+
+It also means that we still could have a short peak when three configs
+are in use (when a new reconfig is requeste while the previous one is
+still active).
+---
+ conf/conf.c | 12 ++++++++++--
+ 1 file changed, 10 insertions(+), 2 deletions(-)
+
+diff --git a/conf/conf.c b/conf/conf.c
+index 4e31de29..7ef729b3 100644
+--- a/conf/conf.c
++++ b/conf/conf.c
+@@ -197,8 +197,12 @@ cleanup:
+ void
+ config_free(struct config *c)
+ {
+- if (c)
+- rfree(c->pool);
++ if (!c)
++ return;
++
++ ASSERT(!c->obstacle_count);
++
++ rfree(c->pool);
+ }
+
+ /**
+@@ -207,10 +211,14 @@ config_free(struct config *c)
+ * This function frees the old configuration (%old_config) that is saved for the
+ * purpose of undo. It is useful before parsing a new config when reconfig is
+ * requested, to avoid keeping three (perhaps memory-heavy) configs together.
++ * Configuration is not freed when it is still active during reconfiguration.
+ */
+ void
+ config_free_old(void)
+ {
++ if (!old_config || old_config->obstacle_count)
++ return;
++
+ tm_stop(config_timer);
+ undo_available = 0;
+
+--
+2.30.2
+
diff --git a/debian/patches/series b/debian/patches/series
index 55e8e570..72d769e7 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1 +1,2 @@
0001-Increase-tests-timeout.patch
+0002-Conf-Fix-too-early-free.patch