diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2006-06-09 19:13:38 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2006-06-18 00:30:22 -0400 |
commit | 3cc0e873986fe594d0e96d07259b11f755325cb2 (patch) | |
tree | 5d3e9a57333a2d7088a6a63c09bc97db98f480af /net/core | |
parent | b38dfee3d616ffadb58d4215e3ff9d1d7921031e (diff) |
[NET]: Warn in __skb_trim if skb is paged
It's better to warn and fail rather than rarely triggering BUG on paths
that incorrectly call skb_trim/__skb_trim on a non-linear skb.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
-rw-r--r-- | net/core/skbuff.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 96cdcbe24ba2..bb7210f4005e 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c | |||
@@ -801,12 +801,10 @@ struct sk_buff *skb_pad(struct sk_buff *skb, int pad) | |||
801 | return nskb; | 801 | return nskb; |
802 | } | 802 | } |
803 | 803 | ||
804 | /* Trims skb to length len. It can change skb pointers, if "realloc" is 1. | 804 | /* Trims skb to length len. It can change skb pointers. |
805 | * If realloc==0 and trimming is impossible without change of data, | ||
806 | * it is BUG(). | ||
807 | */ | 805 | */ |
808 | 806 | ||
809 | int ___pskb_trim(struct sk_buff *skb, unsigned int len, int realloc) | 807 | int ___pskb_trim(struct sk_buff *skb, unsigned int len) |
810 | { | 808 | { |
811 | int offset = skb_headlen(skb); | 809 | int offset = skb_headlen(skb); |
812 | int nfrags = skb_shinfo(skb)->nr_frags; | 810 | int nfrags = skb_shinfo(skb)->nr_frags; |
@@ -816,7 +814,6 @@ int ___pskb_trim(struct sk_buff *skb, unsigned int len, int realloc) | |||
816 | int end = offset + skb_shinfo(skb)->frags[i].size; | 814 | int end = offset + skb_shinfo(skb)->frags[i].size; |
817 | if (end > len) { | 815 | if (end > len) { |
818 | if (skb_cloned(skb)) { | 816 | if (skb_cloned(skb)) { |
819 | BUG_ON(!realloc); | ||
820 | if (pskb_expand_head(skb, 0, 0, GFP_ATOMIC)) | 817 | if (pskb_expand_head(skb, 0, 0, GFP_ATOMIC)) |
821 | return -ENOMEM; | 818 | return -ENOMEM; |
822 | } | 819 | } |