diff mbox series

[1/1] net:ipv6: check return value of pskb_trim()

Message ID 20230715094613.37897-1-ruc_gongyuanjun@163.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series [1/1] net:ipv6: check return value of pskb_trim() | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1342 this patch: 1342
netdev/cc_maintainers warning 3 maintainers not CCed: kuba@kernel.org edumazet@google.com pabeni@redhat.com
netdev/build_clang success Errors and warnings before: 1365 this patch: 1365
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 1365 this patch: 1365
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 12 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Yuanjun Gong July 15, 2023, 9:46 a.m. UTC
goto tx_err if an unexpected result is returned by pskb_tirm()
in ip6erspan_tunnel_xmit().

Signed-off-by: Yuanjun Gong <ruc_gongyuanjun@163.com>
---
 net/ipv6/ip6_gre.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

David Ahern July 15, 2023, 3:03 p.m. UTC | #1
On 7/15/23 3:46 AM, Yuanjun Gong wrote:
> goto tx_err if an unexpected result is returned by pskb_tirm()

s/pskb_tirm/pskb_trim/

> in ip6erspan_tunnel_xmit().
> 
> Signed-off-by: Yuanjun Gong <ruc_gongyuanjun@163.com>
> ---
>  net/ipv6/ip6_gre.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
> index da80974ad23a..92220b02e99f 100644
> --- a/net/ipv6/ip6_gre.c
> +++ b/net/ipv6/ip6_gre.c
> @@ -955,8 +955,10 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,
>  		goto tx_err;
>  
>  	if (skb->len > dev->mtu + dev->hard_header_len) {
> -		pskb_trim(skb, dev->mtu + dev->hard_header_len);
> -		truncate = true;
> +		if (pskb_trim(skb, dev->mtu + dev->hard_header_len))
> +			goto tx_err;
> +		else
> +			truncate = true;
>  	}
>  
>  	nhoff = skb_network_offset(skb);

no need for the `else`:
		if (pskb_trim(skb, dev->mtu + dev->hard_header_len))
			goto tx_err;

		truncate = true;
diff mbox series

Patch

diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
index da80974ad23a..92220b02e99f 100644
--- a/net/ipv6/ip6_gre.c
+++ b/net/ipv6/ip6_gre.c
@@ -955,8 +955,10 @@  static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,
 		goto tx_err;
 
 	if (skb->len > dev->mtu + dev->hard_header_len) {
-		pskb_trim(skb, dev->mtu + dev->hard_header_len);
-		truncate = true;
+		if (pskb_trim(skb, dev->mtu + dev->hard_header_len))
+			goto tx_err;
+		else
+			truncate = true;
 	}
 
 	nhoff = skb_network_offset(skb);