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 |
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 --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);
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(-)