net: dsa: add error handling for pskb_trim_rcsum

Message ID 1528694795-32000-1-git-send-email-jiazhouyang09@gmail.com
State Accepted
Delegated to: David Miller
Headers show
Series
  • net: dsa: add error handling for pskb_trim_rcsum
Related show

Commit Message

Zhouyang Jia June 11, 2018, 5:26 a.m.
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>
---
 net/dsa/tag_trailer.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

David Miller June 11, 2018, 9:20 p.m. | #1
From: Zhouyang Jia <jiazhouyang09@gmail.com>
Date: Mon, 11 Jun 2018 13:26:35 +0800

> 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>

Applied and queued up for -stable, thanks.

Patch

diff --git a/net/dsa/tag_trailer.c b/net/dsa/tag_trailer.c
index 7d20e1f..56197f0 100644
--- a/net/dsa/tag_trailer.c
+++ b/net/dsa/tag_trailer.c
@@ -75,7 +75,8 @@  static struct sk_buff *trailer_rcv(struct sk_buff *skb, struct net_device *dev,
 	if (!skb->dev)
 		return NULL;
 
-	pskb_trim_rcsum(skb, skb->len - 4);
+	if (pskb_trim_rcsum(skb, skb->len - 4))
+		return NULL;
 
 	return skb;
 }