batman-adv: Don't free unicast skb on failure
PATCH 1/1 batman-adv: Don't free unicast skb on failure
The soft-interface transmission function expects that the unicast skb is still available when a send failed. Otherwise we would try to free the skb twice and create many different and hard to debug memory access failures due to access on not (anymore) allocated memory.
--- unicast.c | 1 - 1 files changed, 0 insertions(+), 1 deletions(-)
unicast.c +0 -1
@@ -264,6 +264,5 @@ int unicast_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv) unlock:spin_unlock_irqrestore (&bat_priv->orig_hash_lock, flags); dropped: -kfree_skb (skb);return 1 ; }
Signature · 1 line
1.7.1
PATCH v2 1/1 batman-adv: Don't double free unicast skb on failure
The soft-interface transmission function expects that the unicast skb is still available when a send failed. This is not true on failed search for a router. Thus we would try to free the skb twice and create many different and hard to debug memory access failures due to access on not (anymore) allocated memory.
---
I decided that it makes more sense that the called function frees the data. This makes it similar to dev_queue_xmit or our send_skb_packet. This also fixes the problem with fragmented unicast packets
soft-interface.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-)
soft-interface.c +3 -2
@@ -182,7 +182,7 @@ int interface_tx(struct sk_buff *skb, struct net_device *soft_iface) }else { ret =unicast_send_skb (skb, bat_priv);if (ret !=0 ) - goto dropped; + goto dropped_freed; } bat_priv->stats.tx_packets++;
@@ -190,8 +190,9 @@ int interface_tx(struct sk_buff *skb, struct net_device *soft_iface) goto end; dropped: - bat_priv->stats.tx_dropped++;kfree_skb (skb); +dropped_freed: + bat_priv->stats.tx_dropped++; end:return NETDEV_TX_OK ; }
Signature · 1 line
1.7.1
Marek Lindner
AppliedRe: [B.A.T.M.A.N.] [PATCHv2] batman-adv: Don't double free unicast skb on failure
Quoted 5 lines · On Sunday 05 September 2010 00:44:30 Sven Eckelmann wrote:
The soft-interface transmission function expects that the unicast skb is still available when a send failed. This is not true on failed search for a router. Thus we would try to free the skb twice and create many different and hard to debug memory access failures due to access on not (anymore) allocated memory.
Applied in revision 1786.
Thanks,
Marek