Skip to content

Commit 5af96b9

Browse files
Marek Lindnersimonwunderlich
authored andcommitted
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 <[email protected]> Signed-off-by: Sven Eckelmann <[email protected]> Signed-off-by: Simon Wunderlich <[email protected]>
1 parent ae3cdc9 commit 5af96b9

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

net/batman-adv/bridge_loop_avoidance.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1772,6 +1772,7 @@ batadv_bla_loopdetect_check(struct batadv_priv *bat_priv, struct sk_buff *skb,
17721772
{
17731773
struct batadv_bla_backbone_gw *backbone_gw;
17741774
struct ethhdr *ethhdr;
1775+
bool ret;
17751776

17761777
ethhdr = eth_hdr(skb);
17771778

@@ -1795,8 +1796,13 @@ batadv_bla_loopdetect_check(struct batadv_priv *bat_priv, struct sk_buff *skb,
17951796
if (unlikely(!backbone_gw))
17961797
return true;
17971798

1798-
queue_work(batadv_event_workqueue, &backbone_gw->report_work);
1799-
/* backbone_gw is unreferenced in the report work function function */
1799+
ret = queue_work(batadv_event_workqueue, &backbone_gw->report_work);
1800+
1801+
/* backbone_gw is unreferenced in the report work function function
1802+
* if queue_work() call was successful
1803+
*/
1804+
if (!ret)
1805+
batadv_backbone_gw_put(backbone_gw);
18001806

18011807
return true;
18021808
}

0 commit comments

Comments
 (0)