Skip to content

Commit

Permalink
net: cdc_eem: fix tx fixup skb leak
Browse files Browse the repository at this point in the history
[ Upstream commit c3b26fd ]

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: 9f722c0 ("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>
  • Loading branch information
Linyu Yuan authored and gregkh committed Jun 23, 2021
1 parent f4de2b4 commit b4f7a9f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/net/usb/cdc_eem.c
Expand Up @@ -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:
Expand Down

0 comments on commit b4f7a9f

Please sign in to comment.