]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
ethernet: atheros: fix a memleak in atl1e_setup_ring_resources
authorZhipeng Lu <alexious@zju.edu.cn>
Thu, 14 Dec 2023 13:04:04 +0000 (21:04 +0800)
committerDavid S. Miller <davem@davemloft.net>
Fri, 15 Dec 2023 10:55:35 +0000 (10:55 +0000)
In the error handling of 'offset > adapter->ring_size', the
tx_ring->tx_buffer allocated by kzalloc should be freed,
instead of 'goto failed' instantly.

Fixes: a6a5325239c2 ("atl1e: Atheros L1E Gigabit Ethernet driver")
Signed-off-by: Zhipeng Lu <alexious@zju.edu.cn>
Reviewed-by: Suman Ghosh <sumang@marvell.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/atheros/atl1e/atl1e_main.c

index 5935be190b9e22064c29978ca14e5d6d1bc2011e..5f2a6fcba96708958f75b9575e8c02950dce7586 100644 (file)
@@ -866,10 +866,13 @@ static int atl1e_setup_ring_resources(struct atl1e_adapter *adapter)
                netdev_err(adapter->netdev, "offset(%d) > ring size(%d) !!\n",
                           offset, adapter->ring_size);
                err = -1;
-               goto failed;
+               goto free_buffer;
        }
 
        return 0;
+free_buffer:
+       kfree(tx_ring->tx_buffer);
+       tx_ring->tx_buffer = NULL;
 failed:
        if (adapter->ring_vir_addr != NULL) {
                dma_free_coherent(&pdev->dev, adapter->ring_size,