linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] net: cdc_eem: fix tx fixup skb leak
@ 2021-06-16 23:32 Linyu Yuan
  2021-06-17 13:23 ` Greg Kroah-Hartman
  2021-06-17 18:40 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Linyu Yuan @ 2021-06-16 23:32 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Oliver Neukum, David S . Miller, Jakub Kicinski
  Cc: linux-usb, netdev, Linyu Yuan

when usbnet transmit a skb, eem fixup it in eem_tx_fixup(),
if skb_copy_expand() failed, it return NULL,
usbnet_start_xmit() will have no chance to free original skb.

fix it by free orginal skb in eem_tx_fixup() first,
then check skb clone status, if failed, return NULL to usbnet.

Fixes: 9f722c0978b0 ("usbnet: CDC EEM support (v5)")
Signed-off-by: Linyu Yuan <linyyuan@codeaurora.org>
---

v2: add Fixes tag

 drivers/net/usb/cdc_eem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/usb/cdc_eem.c b/drivers/net/usb/cdc_eem.c
index 2e60bc1b9a6b..359ea0d10e59 100644
--- a/drivers/net/usb/cdc_eem.c
+++ b/drivers/net/usb/cdc_eem.c
@@ -123,10 +123,10 @@ static struct sk_buff *eem_tx_fixup(struct usbnet *dev, struct sk_buff *skb,
 	}
 
 	skb2 = skb_copy_expand(skb, EEM_HEAD, ETH_FCS_LEN + padlen, flags);
+	dev_kfree_skb_any(skb);
 	if (!skb2)
 		return NULL;
 
-	dev_kfree_skb_any(skb);
 	skb = skb2;
 
 done:
-- 
2.25.1


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

* Re: [PATCH v2] net: cdc_eem: fix tx fixup skb leak
  2021-06-16 23:32 [PATCH v2] net: cdc_eem: fix tx fixup skb leak Linyu Yuan
@ 2021-06-17 13:23 ` Greg Kroah-Hartman
  2021-06-17 18:40 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Greg Kroah-Hartman @ 2021-06-17 13:23 UTC (permalink / raw)
  To: Linyu Yuan
  Cc: Oliver Neukum, David S . Miller, Jakub Kicinski, linux-usb, netdev

On Thu, Jun 17, 2021 at 07:32:32AM +0800, Linyu Yuan wrote:
> when usbnet transmit a skb, eem fixup it in eem_tx_fixup(),
> if skb_copy_expand() failed, it return NULL,
> usbnet_start_xmit() will have no chance to free original skb.
> 
> fix it by free orginal skb in eem_tx_fixup() first,
> then check skb clone status, if failed, return NULL to usbnet.
> 
> Fixes: 9f722c0978b0 ("usbnet: CDC EEM support (v5)")
> Signed-off-by: Linyu Yuan <linyyuan@codeaurora.org>
> ---
> 
> v2: add Fixes tag
> 
>  drivers/net/usb/cdc_eem.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/usb/cdc_eem.c b/drivers/net/usb/cdc_eem.c
> index 2e60bc1b9a6b..359ea0d10e59 100644
> --- a/drivers/net/usb/cdc_eem.c
> +++ b/drivers/net/usb/cdc_eem.c
> @@ -123,10 +123,10 @@ static struct sk_buff *eem_tx_fixup(struct usbnet *dev, struct sk_buff *skb,
>  	}
>  
>  	skb2 = skb_copy_expand(skb, EEM_HEAD, ETH_FCS_LEN + padlen, flags);
> +	dev_kfree_skb_any(skb);
>  	if (!skb2)
>  		return NULL;
>  
> -	dev_kfree_skb_any(skb);
>  	skb = skb2;
>  
>  done:
> -- 
> 2.25.1
> 

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

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

* Re: [PATCH v2] net: cdc_eem: fix tx fixup skb leak
  2021-06-16 23:32 [PATCH v2] net: cdc_eem: fix tx fixup skb leak Linyu Yuan
  2021-06-17 13:23 ` Greg Kroah-Hartman
@ 2021-06-17 18:40 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-06-17 18:40 UTC (permalink / raw)
  To: Linyu Yuan; +Cc: gregkh, oliver, davem, kuba, linux-usb, netdev

Hello:

This patch was applied to netdev/net.git (refs/heads/master):

On Thu, 17 Jun 2021 07:32:32 +0800 you wrote:
> when usbnet transmit a skb, eem fixup it in eem_tx_fixup(),
> if skb_copy_expand() failed, it return NULL,
> usbnet_start_xmit() will have no chance to free original skb.
> 
> fix it by free orginal skb in eem_tx_fixup() first,
> then check skb clone status, if failed, return NULL to usbnet.
> 
> [...]

Here is the summary with links:
  - [v2] net: cdc_eem: fix tx fixup skb leak
    https://git.kernel.org/netdev/net/c/c3b26fdf1b32

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2021-06-17 18:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-16 23:32 [PATCH v2] net: cdc_eem: fix tx fixup skb leak Linyu Yuan
2021-06-17 13:23 ` Greg Kroah-Hartman
2021-06-17 18:40 ` patchwork-bot+netdevbpf

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).