net: dsa: add error handling for pskb_trim_rcsum
authorZhouyang Jia <jiazhouyang09@gmail.com>
Mon, 11 Jun 2018 05:26:35 +0000 (13:26 +0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 11 Jun 2018 21:19:38 +0000 (14:19 -0700)
When pskb_trim_rcsum fails, the lack of error-handling code may
cause unexpected results.

This patch adds error-handling code after calling pskb_trim_rcsum.

Signed-off-by: Zhouyang Jia <jiazhouyang09@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/dsa/tag_trailer.c

index 7d20e1f3de28a4826a9e39667a2a7a1a931cbb2b..56197f0d9608de25b857ad2f902c554002a2929b 100644 (file)
@@ -75,7 +75,8 @@ static struct sk_buff *trailer_rcv(struct sk_buff *skb, struct net_device *dev,
        if (!skb->dev)
                return NULL;
 
        if (!skb->dev)
                return NULL;
 
-       pskb_trim_rcsum(skb, skb->len - 4);
+       if (pskb_trim_rcsum(skb, skb->len - 4))
+               return NULL;
 
        return skb;
 }
 
        return skb;
 }