netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: xfrm: fix return value check in ipcomp_compress
@ 2023-10-06 11:41 Ma Ke
  2023-10-06 11:47 ` Florian Westphal
  0 siblings, 1 reply; 3+ messages in thread
From: Ma Ke @ 2023-10-06 11:41 UTC (permalink / raw)
  To: steffen.klassert, herbert, davem, edumazet, kuba, pabeni
  Cc: netdev, linux-kernel, Ma Ke

In ipcomp_compress, to avoid an unexpected result returned by
pskb_trim, we should check the return value of pskb_trim().

Signed-off-by: Ma Ke <make_ruc2021@163.com>
---
 net/xfrm/xfrm_ipcomp.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/xfrm/xfrm_ipcomp.c b/net/xfrm/xfrm_ipcomp.c
index 9c0fa0e1786a..5f2e6edadf48 100644
--- a/net/xfrm/xfrm_ipcomp.c
+++ b/net/xfrm/xfrm_ipcomp.c
@@ -144,7 +144,9 @@ static int ipcomp_compress(struct xfrm_state *x, struct sk_buff *skb)
 	memcpy(start + sizeof(struct ip_comp_hdr), scratch, dlen);
 	local_bh_enable();
 
-	pskb_trim(skb, dlen + sizeof(struct ip_comp_hdr));
+	err = pskb_trim(skb, dlen + sizeof(struct ip_comp_hdr));
+	if (unlikely(err))
+		goto out;
 	return 0;
 
 out:
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-10-06 11:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-06 11:41 [PATCH] net: xfrm: fix return value check in ipcomp_compress Ma Ke
2023-10-06 11:47 ` Florian Westphal
2023-10-06 11:59   ` Florian Westphal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).