batman-adv: Merge bugfixes from 2018.3
[feed/routing.git] / batman-adv / patches / 0049-batman-adv-fix-backbone_gw-refcount-on-queue_work-fa.patch
diff --git a/batman-adv/patches/0049-batman-adv-fix-backbone_gw-refcount-on-queue_work-fa.patch b/batman-adv/patches/0049-batman-adv-fix-backbone_gw-refcount-on-queue_work-fa.patch
new file mode 100644 (file)
index 0000000..b47371a
--- /dev/null
@@ -0,0 +1,45 @@
+From: Marek Lindner <mareklindner@neomailbox.ch>
+Date: Fri, 7 Sep 2018 05:45:54 +0800
+Subject: [PATCH] batman-adv: fix backbone_gw refcount on queue_work() failure
+
+The backbone_gw refcounter is to be decreased by the queued work and
+currently is never decreased if the queue_work() call fails.
+Fix by checking the queue_work() return value and decrease refcount
+if necessary.
+
+Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
+Signed-off-by: Sven Eckelmann <sven@narfation.org>
+
+Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/24d83a50421c1c5d39cd9c015516a1a293ae8d0c
+---
+ net/batman-adv/bridge_loop_avoidance.c | 10 ++++++++--
+ 1 file changed, 8 insertions(+), 2 deletions(-)
+
+diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c
+index aecf34503e95d9aa723449ddbf0bb3035336b878..258a74fd1c237fbf1b81dfc1c48720d8359b0ecc 100644
+--- a/net/batman-adv/bridge_loop_avoidance.c
++++ b/net/batman-adv/bridge_loop_avoidance.c
+@@ -1767,6 +1767,7 @@ batadv_bla_loopdetect_check(struct batadv_priv *bat_priv, struct sk_buff *skb,
+ {
+       struct batadv_bla_backbone_gw *backbone_gw;
+       struct ethhdr *ethhdr;
++      bool ret;
+       ethhdr = eth_hdr(skb);
+@@ -1790,8 +1791,13 @@ batadv_bla_loopdetect_check(struct batadv_priv *bat_priv, struct sk_buff *skb,
+       if (unlikely(!backbone_gw))
+               return true;
+-      queue_work(batadv_event_workqueue, &backbone_gw->report_work);
+-      /* backbone_gw is unreferenced in the report work function function */
++      ret = queue_work(batadv_event_workqueue, &backbone_gw->report_work);
++
++      /* backbone_gw is unreferenced in the report work function function
++       * if queue_work() call was successful
++       */
++      if (!ret)
++              batadv_backbone_gw_put(backbone_gw);
+       return true;
+ }