diff options
author | Marek Lindner <lindner_marek@yahoo.de> | 2010-02-19 16:18:10 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-03-03 16:43:03 -0800 |
commit | da6d6c7ac366ad3189e494cd78376db7a4f40d59 (patch) | |
tree | d74f8a2adc3027b2c161e164c605954cffd34778 /drivers/staging | |
parent | 8d03847c090b12694fb9fa81dbefa7b3e4f10f1d (diff) | |
download | op-kernel-dev-da6d6c7ac366ad3189e494cd78376db7a4f40d59.zip op-kernel-dev-da6d6c7ac366ad3189e494cd78376db7a4f40d59.tar.gz |
Staging: 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>
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging')
-rw-r--r-- | drivers/staging/batman-adv/hard-interface.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/drivers/staging/batman-adv/hard-interface.c b/drivers/staging/batman-adv/hard-interface.c index f8b1ba3..0f94158 100644 --- a/drivers/staging/batman-adv/hard-interface.c +++ b/drivers/staging/batman-adv/hard-interface.c @@ -426,10 +426,11 @@ int batman_skb_recv(struct sk_buff *skb, struct net_device *dev, 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)) @@ -444,7 +445,7 @@ int batman_skb_recv(struct sk_buff *skb, struct net_device *dev, 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; @@ -490,6 +491,7 @@ int batman_skb_recv(struct sk_buff *skb, struct net_device *dev, default: ret = NET_RX_DROP; } + if (ret == NET_RX_DROP) kfree_skb(skb); @@ -500,9 +502,9 @@ int batman_skb_recv(struct sk_buff *skb, struct net_device *dev, return NET_RX_SUCCESS; err_free: - kfree_skb(skb); - return NET_RX_DROP; - + kfree_skb(skb); +err_out: + return NET_RX_DROP; } |