2023-12-14 13:05:27

by Zhipeng Lu

[permalink] [raw]
Subject: [PATCH] [v3] ethernet: atheros: fix a memleak in atl1e_setup_ring_resources

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 <[email protected]>
Reviewed-by: Suman Ghosh <[email protected]>
---

Changelog:

v2: Setting tx_ring->tx_buffer to NULL after free.
v3: Moving free and set-null operation to a new label free_buffer.
---
drivers/net/ethernet/atheros/atl1e/atl1e_main.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/atheros/atl1e/atl1e_main.c b/drivers/net/ethernet/atheros/atl1e/atl1e_main.c
index 5935be190b9e..5f2a6fcba967 100644
--- a/drivers/net/ethernet/atheros/atl1e/atl1e_main.c
+++ b/drivers/net/ethernet/atheros/atl1e/atl1e_main.c
@@ -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,
--
2.34.1


2023-12-15 11:00:50

by patchwork-bot+netdevbpf

[permalink] [raw]
Subject: Re: [PATCH] [v3] ethernet: atheros: fix a memleak in atl1e_setup_ring_resources

Hello:

This patch was applied to netdev/net.git (main)
by David S. Miller <[email protected]>:

On Thu, 14 Dec 2023 21:04:04 +0800 you wrote:
> 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 <[email protected]>
> Reviewed-by: Suman Ghosh <[email protected]>
>
> [...]

Here is the summary with links:
- [v3] ethernet: atheros: fix a memleak in atl1e_setup_ring_resources
https://git.kernel.org/netdev/net/c/309fdb1c33fe

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html