* [PATCH net-next] net: libwx: fix memory leak in wx_setup_rx_resources
@ 2023-04-18 6:54 Zhengchao Shao
2023-04-19 15:19 ` Simon Horman
2023-04-20 14:00 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Zhengchao Shao @ 2023-04-18 6:54 UTC (permalink / raw)
To: netdev, jiawenwu, mengyuanlou, davem, edumazet, kuba, pabeni
Cc: yang.lee, shaozhengchao, error27
When wx_alloc_page_pool() failed in wx_setup_rx_resources(), it doesn't
release DMA buffer. Add dma_free_coherent() in the error path to release
the DMA buffer.
Fixes: 850b971110b2 ("net: libwx: Allocate Rx and Tx resources")
Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
---
drivers/net/ethernet/wangxun/libwx/wx_lib.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/wangxun/libwx/wx_lib.c b/drivers/net/ethernet/wangxun/libwx/wx_lib.c
index eb89a274083e..1e8d8b7b0c62 100644
--- a/drivers/net/ethernet/wangxun/libwx/wx_lib.c
+++ b/drivers/net/ethernet/wangxun/libwx/wx_lib.c
@@ -1798,10 +1798,13 @@ static int wx_setup_rx_resources(struct wx_ring *rx_ring)
ret = wx_alloc_page_pool(rx_ring);
if (ret < 0) {
dev_err(rx_ring->dev, "Page pool creation failed: %d\n", ret);
- goto err;
+ goto err_desc;
}
return 0;
+
+err_desc:
+ dma_free_coherent(dev, rx_ring->size, rx_ring->desc, rx_ring->dma);
err:
kvfree(rx_ring->rx_buffer_info);
rx_ring->rx_buffer_info = NULL;
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] net: libwx: fix memory leak in wx_setup_rx_resources
2023-04-18 6:54 [PATCH net-next] net: libwx: fix memory leak in wx_setup_rx_resources Zhengchao Shao
@ 2023-04-19 15:19 ` Simon Horman
2023-04-20 14:00 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Simon Horman @ 2023-04-19 15:19 UTC (permalink / raw)
To: Zhengchao Shao
Cc: netdev, jiawenwu, mengyuanlou, davem, edumazet, kuba, pabeni,
yang.lee, error27
On Tue, Apr 18, 2023 at 02:54:50PM +0800, Zhengchao Shao wrote:
> When wx_alloc_page_pool() failed in wx_setup_rx_resources(), it doesn't
> release DMA buffer. Add dma_free_coherent() in the error path to release
> the DMA buffer.
>
> Fixes: 850b971110b2 ("net: libwx: Allocate Rx and Tx resources")
> Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] net: libwx: fix memory leak in wx_setup_rx_resources
2023-04-18 6:54 [PATCH net-next] net: libwx: fix memory leak in wx_setup_rx_resources Zhengchao Shao
2023-04-19 15:19 ` Simon Horman
@ 2023-04-20 14:00 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-04-20 14:00 UTC (permalink / raw)
To: Zhengchao Shao
Cc: netdev, jiawenwu, mengyuanlou, davem, edumazet, kuba, pabeni,
yang.lee, error27
Hello:
This patch was applied to netdev/net-next.git (main)
by Paolo Abeni <pabeni@redhat.com>:
On Tue, 18 Apr 2023 14:54:50 +0800 you wrote:
> When wx_alloc_page_pool() failed in wx_setup_rx_resources(), it doesn't
> release DMA buffer. Add dma_free_coherent() in the error path to release
> the DMA buffer.
>
> Fixes: 850b971110b2 ("net: libwx: Allocate Rx and Tx resources")
> Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
>
> [...]
Here is the summary with links:
- [net-next] net: libwx: fix memory leak in wx_setup_rx_resources
https://git.kernel.org/netdev/net-next/c/e315e7b83a22
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] 3+ messages in thread
end of thread, other threads:[~2023-04-20 14:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-18 6:54 [PATCH net-next] net: libwx: fix memory leak in wx_setup_rx_resources Zhengchao Shao
2023-04-19 15:19 ` Simon Horman
2023-04-20 14: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;
as well as URLs for NNTP newsgroup(s).