diff mbox series

[1/1] drivers:net: fix return value check in be_lancer_xmit_workarounds

Message ID 20230717144532.22037-1-ruc_gongyuanjun@163.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series [1/1] drivers:net: fix return value check in be_lancer_xmit_workarounds | 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: 1349 this patch: 1349
netdev/cc_maintainers warning 4 maintainers not CCed: kuba@kernel.org edumazet@google.com davem@davemloft.net 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: 1372 this patch: 1372
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 9 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 17, 2023, 2:45 p.m. UTC
in be_lancer_xmit_workarounds, it should go to label 'err' if
an unexpected value is returned by pskb_trim.

Signed-off-by: Yuanjun Gong <ruc_gongyuanjun@163.com>
---
 drivers/net/ethernet/emulex/benet/be_main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Kuniyuki Iwashima July 17, 2023, 7:32 p.m. UTC | #1
From: Yuanjun Gong <ruc_gongyuanjun@163.com>
Date: Mon, 17 Jul 2023 22:45:32 +0800
> in be_lancer_xmit_workarounds, it should go to label 'err' if
> an unexpected value is returned by pskb_trim.
>

Fixes tag needed here.

> Signed-off-by: Yuanjun Gong <ruc_gongyuanjun@163.com>
> ---
>  drivers/net/ethernet/emulex/benet/be_main.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
> index 18c2fc880d09..eba29a2e0e8b 100644
> --- a/drivers/net/ethernet/emulex/benet/be_main.c
> +++ b/drivers/net/ethernet/emulex/benet/be_main.c
> @@ -1138,7 +1138,8 @@ static struct sk_buff *be_lancer_xmit_workarounds(struct be_adapter *adapter,
>  	    (lancer_chip(adapter) || BE3_chip(adapter) ||
>  	     skb_vlan_tag_present(skb)) && is_ipv4_pkt(skb)) {
>  		ip = (struct iphdr *)ip_hdr(skb);
> -		pskb_trim(skb, eth_hdr_len + ntohs(ip->tot_len));
> +		if (unlikely(pskb_trim(skb, eth_hdr_len + ntohs(ip->tot_len))))
> +			goto err;

This should be `goto tx_drop`, or we'll leak skb.


>  	}
>  
>  	/* If vlan tag is already inlined in the packet, skip HW VLAN
> -- 
> 2.17.1
Simon Horman July 19, 2023, 8:16 p.m. UTC | #2
On Mon, Jul 17, 2023 at 12:32:59PM -0700, Kuniyuki Iwashima wrote:
> From: Yuanjun Gong <ruc_gongyuanjun@163.com>
> Date: Mon, 17 Jul 2023 22:45:32 +0800
> > in be_lancer_xmit_workarounds, it should go to label 'err' if
> > an unexpected value is returned by pskb_trim.
> >
> 
> Fixes tag needed here.

Further to that, assuming this is a fix, then the patch should also be
targeted at the net tree, as opposed to the net-next tree.

	Subject: [PATCH net v2] ...

And the prefix should probably be 'be2net:'

	Subject: [PATCH net v2] be2net: ...

...
diff mbox series

Patch

diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
index 18c2fc880d09..eba29a2e0e8b 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -1138,7 +1138,8 @@  static struct sk_buff *be_lancer_xmit_workarounds(struct be_adapter *adapter,
 	    (lancer_chip(adapter) || BE3_chip(adapter) ||
 	     skb_vlan_tag_present(skb)) && is_ipv4_pkt(skb)) {
 		ip = (struct iphdr *)ip_hdr(skb);
-		pskb_trim(skb, eth_hdr_len + ntohs(ip->tot_len));
+		if (unlikely(pskb_trim(skb, eth_hdr_len + ntohs(ip->tot_len))))
+			goto err;
 	}
 
 	/* If vlan tag is already inlined in the packet, skip HW VLAN