Author: marek Date: 2010-02-14 17:30:15 +0100 (Sun, 14 Feb 2010) New Revision: 1572
Modified: trunk/batman-adv-kernelland/hard-interface.c Log: batman-adv: avoid crash on memory allocation error
skb_share_check() returns NULL if it can't allocate more memory but it still frees the skbuff.
Signed-off-by: Marek Lindner lindner_marek@yahoo.de
Modified: trunk/batman-adv-kernelland/hard-interface.c =================================================================== --- trunk/batman-adv-kernelland/hard-interface.c 2010-02-14 15:05:18 UTC (rev 1571) +++ trunk/batman-adv-kernelland/hard-interface.c 2010-02-14 16:30:15 UTC (rev 1572) @@ -427,10 +427,11 @@ struct net_device_stats *stats; int ret;
- skb = skb_share_check(skb, GFP_ATOMIC); + skb = skb_share_check(skb, GFP_ATOMIC);
- if (skb == NULL) - goto err_free; + /* skb was released by skb_share_check() */ + if (!skb) + goto err_out;
/* packet should hold at least type and version */ if (unlikely(skb_headlen(skb) < 2)) @@ -445,7 +446,7 @@ if (!batman_if) goto err_free;
- stats = (struct net_device_stats *) dev_get_stats(skb->dev); + stats = (struct net_device_stats *)dev_get_stats(skb->dev); if (stats) { stats->rx_packets++; stats->rx_bytes += skb->len; @@ -491,6 +492,7 @@ default: ret = NET_RX_DROP; } + if (ret == NET_RX_DROP) kfree_skb(skb);
@@ -501,9 +503,9 @@ return NET_RX_SUCCESS;
err_free: - kfree_skb(skb); - return NET_RX_DROP; - + kfree_skb(skb); +err_out: + return NET_RX_DROP; }