]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
net: sxgbe: free TX rings on RX allocation failure
authorChenguang Zhao <zhaochenguang@kylinos.cn>
Thu, 23 Jul 2026 02:18:19 +0000 (10:18 +0800)
committerDavid S. Miller <davem@davemloft.net>
Wed, 29 Jul 2026 08:33:10 +0000 (09:33 +0100)
When RX descriptor ring allocation fails, init_dma_desc_rings() only
frees the partially allocated RX rings and returns. The TX rings that
were allocated earlier in the same function are leaked.

Rearrange error labels to clean up TX rings upon RX failures.

Fixes: 1edb9ca69e8a ("net: sxgbe: add basic framework for Samsung 10Gb ethernet driver")
Signed-off-by: Chenguang Zhao <zhaochenguang@kylinos.cn>
Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c

index 5051ada43d2fa614b8948cf044baa5b1e47269b6..9b48a587d5c2e1427e644a549074b6de6d2ebe2d 100644 (file)
@@ -597,14 +597,13 @@ static int init_dma_desc_rings(struct net_device *netd)
 
        return 0;
 
-txalloc_err:
-       while (queue_num--)
-               free_tx_ring(priv->device, priv->txq[queue_num], tx_rsize);
-       return ret;
-
 rxalloc_err:
        while (queue_num--)
                free_rx_ring(priv->device, priv->rxq[queue_num], rx_rsize);
+       queue_num = SXGBE_TX_QUEUES;
+txalloc_err:
+       while (queue_num--)
+               free_tx_ring(priv->device, priv->txq[queue_num], tx_rsize);
        return ret;
 }