net: cdc_eem: fix tx fixup skb leak
authorLinyu Yuan <linyyuan@codeaurora.org>
Wed, 16 Jun 2021 23:32:32 +0000 (07:32 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 23 Jun 2021 12:42:47 +0000 (14:42 +0200)
commit05b2b9f7d24b5663d9b47427fe1555bdafd3ea02
tree1e61c585f5a4520322fd888286c40fd88b025018
parent290b0b6432e2599021db0b8d6046f756d931c29f
net: cdc_eem: fix tx fixup skb leak

[ Upstream commit c3b26fdf1b32f91c7a3bc743384b4a298ab53ad7 ]

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>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/usb/cdc_eem.c