summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZhipeng Lu <alexious@zju.edu.cn>2023-12-14 21:04:04 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-01-08 11:27:34 +0100
commita2de8f562a5ba379f0abfd2de8db6e5c38204422 (patch)
tree2101da641adb24df3daa1a59e5b03d4516921ee8
parent28702d500a158c10fdbabce0cc409600c1d9afdc (diff)
downloadlinux-stable-a2de8f562a5ba379f0abfd2de8db6e5c38204422.tar.gz
linux-stable-a2de8f562a5ba379f0abfd2de8db6e5c38204422.tar.bz2
linux-stable-a2de8f562a5ba379f0abfd2de8db6e5c38204422.zip
ethernet: atheros: fix a memleak in atl1e_setup_ring_resources
[ Upstream commit 309fdb1c33fe726d92d0030481346f24e1b01f07 ] 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> Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--drivers/net/ethernet/atheros/atl1e/atl1e_main.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/net/ethernet/atheros/atl1e/atl1e_main.c b/drivers/net/ethernet/atheros/atl1e/atl1e_main.c
index e4d58c7aeaf8..c72ba133072f 100644
--- a/drivers/net/ethernet/atheros/atl1e/atl1e_main.c
+++ b/drivers/net/ethernet/atheros/atl1e/atl1e_main.c
@@ -881,10 +881,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) {
pci_free_consistent(pdev, adapter->ring_size,