]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net: usb: ax88179_178a: fix skb leak in ax88179_tx_fixup()
authorYi Cong <yicong@kylinos.cn>
Wed, 29 Jul 2026 03:04:36 +0000 (11:04 +0800)
committerJakub Kicinski <kuba@kernel.org>
Tue, 4 Aug 2026 00:50:51 +0000 (17:50 -0700)
When the interface has NETIF_F_SG enabled and skb_linearize() fails in
ax88179_tx_fixup(), the function returns NULL without freeing the skb.

usbnet_start_xmit() treats a NULL return from tx_fixup() as a drop
(info->flags does not set FLAG_MULTI_PACKET for this driver), jumping
to the "drop" label where it does `if (skb) dev_kfree_skb_any(skb)`.
Because tx_fixup() returned NULL, the local skb variable in
usbnet_start_xmit() is NULL, so the original skb is never freed — a
memory leak on every TX frame whose linearization fails (i.e. under
memory pressure).

Free the skb before returning, matching the error handling already used
for the pskb_expand_head() failure path in the same function.

Fixes: 16b1c4e01c89 ("net: usb: ax88179_178a: add TSO feature")
Cc: stable@vger.kernel.org
Signed-off-by: Yi Cong <yicong@kylinos.cn>
Link: https://patch.msgid.link/20260729030436.3420477-1-cong.yi@linux.dev
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/usb/ax88179_178a.c

index 98f899ea2e9462f1ba99281a875385241745458b..81d8412ce8e2fac981df076ea1385e6e87525cfe 100644 (file)
@@ -1487,8 +1487,10 @@ ax88179_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags)
 
        headroom = skb_headroom(skb) - 8;
 
-       if ((dev->net->features & NETIF_F_SG) && skb_linearize(skb))
+       if ((dev->net->features & NETIF_F_SG) && skb_linearize(skb)) {
+               dev_kfree_skb_any(skb);
                return NULL;
+       }
 
        if ((skb_header_cloned(skb) || headroom < 0) &&
            pskb_expand_head(skb, headroom < 0 ? 8 : 0, 0, GFP_ATOMIC)) {