Skip to content

Commit be18101

Browse files
committed
batman-adv: fix reference counting imbalance while sending fragment
In the new fragmentation code the batadv_frag_send_packet() function obtains a reference to the primary_if, but it does not release it upon return. This reference imbalance prevents the primary_if (and then the related netdevice) to be properly released on shut down. Fix this by releasing the primary_if in batadv_frag_send_packet(). Introduced by ee75ed8 ("batman-adv: Fragment and send skbs larger than mtu") Cc: Martin Hundebøll <martin@hundeboll.net> Signed-off-by: Antonio Quartulli <antonio@open-mesh.com> Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch> Acked-by: Martin Hundebøll <martin@hundeboll.net>
1 parent 16a4142 commit be18101

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

‎net/batman-adv/fragmentation.c‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -418,12 +418,13 @@ bool batadv_frag_send_packet(struct sk_buff *skb,
418418
struct batadv_neigh_node *neigh_node)
419419
{
420420
struct batadv_priv *bat_priv;
421-
struct batadv_hard_iface *primary_if;
421+
struct batadv_hard_iface *primary_if = NULL;
422422
struct batadv_frag_packet frag_header;
423423
struct sk_buff *skb_fragment;
424424
unsigned mtu = neigh_node->if_incoming->net_dev->mtu;
425425
unsigned header_size = sizeof(frag_header);
426426
unsigned max_fragment_size, max_packet_size;
427+
bool ret = false;
427428

428429
/* To avoid merge and refragmentation at next-hops we never send
429430
* fragments larger than BATADV_FRAG_MAX_FRAG_SIZE
@@ -483,7 +484,11 @@ bool batadv_frag_send_packet(struct sk_buff *skb,
483484
skb->len + ETH_HLEN);
484485
batadv_send_skb_packet(skb, neigh_node->if_incoming, neigh_node->addr);
485486

486-
return true;
487+
ret = true;
488+
487489
out_err:
488-
return false;
490+
if (primary_if)
491+
batadv_hardif_free_ref(primary_if);
492+
493+
return ret;
489494
}

0 commit comments

Comments
 (0)