public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] [v3] ethernet: atheros: fix a memleak in atl1e_setup_ring_resources
@ 2023-12-14 13:04 Zhipeng Lu
  2023-12-15 11:00 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Zhipeng Lu @ 2023-12-14 13:04 UTC (permalink / raw)
  To: alexious
  Cc: Suman Ghosh, Chris Snook, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Simon Horman, Yuanjun Gong,
	Jeff Garzik, Jie Yang, netdev, linux-kernel

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>
---

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] [v3] ethernet: atheros: fix a memleak in atl1e_setup_ring_resources
  2023-12-14 13:04 [PATCH] [v3] ethernet: atheros: fix a memleak in atl1e_setup_ring_resources Zhipeng Lu
@ 2023-12-15 11:00 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-12-15 11:00 UTC (permalink / raw)
  To: Zhipeng Lu
  Cc: sumang, chris.snook, davem, edumazet, kuba, pabeni, horms,
	ruc_gongyuanjun, jgarzik, jie.yang, netdev, linux-kernel

Hello:

This patch was applied to netdev/net.git (main)
by David S. Miller <davem@davemloft.net>:

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 <alexious@zju.edu.cn>
> Reviewed-by: Suman Ghosh <sumang@marvell.com>
> 
> [...]

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



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-12-15 11:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-14 13:04 [PATCH] [v3] ethernet: atheros: fix a memleak in atl1e_setup_ring_resources Zhipeng Lu
2023-12-15 11:00 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox