[PATCH 4.14 04/52] net: dsa: add error handling for pskb_trim_rcsum

From: Greg Kroah-Hartman
Date: Sun Jun 24 2018 - 11:25:21 EST


4.14-stable review patch. If anyone has any objections, please let me know.

------------------

From: Zhouyang Jia <jiazhouyang09@xxxxxxxxx>

[ Upstream commit 349b71d6f427ff8211adf50839dbbff3f27c1805 ]

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@xxxxxxxxx>
Signed-off-by: David S. Miller <davem@xxxxxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
net/dsa/tag_trailer.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

--- a/net/dsa/tag_trailer.c
+++ b/net/dsa/tag_trailer.c
@@ -79,7 +79,8 @@ static struct sk_buff *trailer_rcv(struc
if (unlikely(ds->cpu_port_mask & BIT(source_port)))
return NULL;

- pskb_trim_rcsum(skb, skb->len - 4);
+ if (pskb_trim_rcsum(skb, skb->len - 4))
+ return NULL;

skb->dev = ds->ports[source_port].netdev;