b.a.t.m.a.n.lists.open-mesh.org archive mirror
 help / color / mirror / Atom feed
* [B.A.T.M.A.N.] [PATCH maint 1/2] batman-adv: fix backbone_gw refcount on queue_work() failure
@ 2018-09-06 21:45 Marek Lindner
  2018-09-06 21:45 ` [B.A.T.M.A.N.] [PATCH maint 2/2] batman-adv: fix hardif_neigh " Marek Lindner
  2018-09-07 11:17 ` [B.A.T.M.A.N.] [PATCH maint 1/2] batman-adv: fix backbone_gw " Sven Eckelmann
  0 siblings, 2 replies; 3+ messages in thread
From: Marek Lindner @ 2018-09-06 21:45 UTC (permalink / raw)
  To: b.a.t.m.a.n; +Cc: Marek Lindner

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>
---
 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 a2de5a44..58c093ca 100644
--- a/net/batman-adv/bridge_loop_avoidance.c
+++ b/net/batman-adv/bridge_loop_avoidance.c
@@ -1772,6 +1772,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);
 
@@ -1795,8 +1796,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;
 }
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [B.A.T.M.A.N.] [PATCH maint 2/2] batman-adv: fix hardif_neigh refcount on queue_work() failure
  2018-09-06 21:45 [B.A.T.M.A.N.] [PATCH maint 1/2] batman-adv: fix backbone_gw refcount on queue_work() failure Marek Lindner
@ 2018-09-06 21:45 ` Marek Lindner
  2018-09-07 11:17 ` [B.A.T.M.A.N.] [PATCH maint 1/2] batman-adv: fix backbone_gw " Sven Eckelmann
  1 sibling, 0 replies; 3+ messages in thread
From: Marek Lindner @ 2018-09-06 21:45 UTC (permalink / raw)
  To: b.a.t.m.a.n; +Cc: Marek Lindner

The hardif_neigh 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>
---
 net/batman-adv/bat_v_elp.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/net/batman-adv/bat_v_elp.c b/net/batman-adv/bat_v_elp.c
index e103c759..9f481cfd 100644
--- a/net/batman-adv/bat_v_elp.c
+++ b/net/batman-adv/bat_v_elp.c
@@ -268,6 +268,7 @@ static void batadv_v_elp_periodic_work(struct work_struct *work)
 	struct batadv_priv *bat_priv;
 	struct sk_buff *skb;
 	u32 elp_interval;
+	bool ret;
 
 	bat_v = container_of(work, struct batadv_hard_iface_bat_v, elp_wq.work);
 	hard_iface = container_of(bat_v, struct batadv_hard_iface, bat_v);
@@ -329,8 +330,11 @@ static void batadv_v_elp_periodic_work(struct work_struct *work)
 		 * may sleep and that is not allowed in an rcu protected
 		 * context. Therefore schedule a task for that.
 		 */
-		queue_work(batadv_event_workqueue,
-			   &hardif_neigh->bat_v.metric_work);
+		ret = queue_work(batadv_event_workqueue,
+				 &hardif_neigh->bat_v.metric_work);
+
+		if (!ret)
+			batadv_hardif_neigh_put(hardif_neigh);
 	}
 	rcu_read_unlock();
 
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [B.A.T.M.A.N.] [PATCH maint 1/2] batman-adv: fix backbone_gw refcount on queue_work() failure
  2018-09-06 21:45 [B.A.T.M.A.N.] [PATCH maint 1/2] batman-adv: fix backbone_gw refcount on queue_work() failure Marek Lindner
  2018-09-06 21:45 ` [B.A.T.M.A.N.] [PATCH maint 2/2] batman-adv: fix hardif_neigh " Marek Lindner
@ 2018-09-07 11:17 ` Sven Eckelmann
  1 sibling, 0 replies; 3+ messages in thread
From: Sven Eckelmann @ 2018-09-07 11:17 UTC (permalink / raw)
  To: b.a.t.m.a.n; +Cc: Marek Lindner

[-- Attachment #1: Type: text/plain, Size: 729 bytes --]

On Donnerstag, 6. September 2018 23:45:54 CEST Marek Lindner wrote:
> 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>
> ---
>  net/batman-adv/bridge_loop_avoidance.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)

Added both patches as 24d83a50421c [1] and 85100b602c12 [2]

Thanks,
	Sven

[1] https://git.open-mesh.org/batman-adv.git/commit/24d83a50421c1c5d39cd9c015516a1a293ae8d0c
[2] https://git.open-mesh.org/batman-adv.git/commit/85100b602c127cecf1bcfd620d20eb867d685df2

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-09-07 11:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-06 21:45 [B.A.T.M.A.N.] [PATCH maint 1/2] batman-adv: fix backbone_gw refcount on queue_work() failure Marek Lindner
2018-09-06 21:45 ` [B.A.T.M.A.N.] [PATCH maint 2/2] batman-adv: fix hardif_neigh " Marek Lindner
2018-09-07 11:17 ` [B.A.T.M.A.N.] [PATCH maint 1/2] batman-adv: fix backbone_gw " Sven Eckelmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).