diff mbox series

[net-next] net: libwx: fix memory leak in wx_setup_rx_resources

Message ID 20230418065450.2268522-1-shaozhengchao@huawei.com (mailing list archive)
State Accepted
Commit e315e7b83a22043bffee450437d7089ef373cbf6
Delegated to: Netdev Maintainers
Headers show
Series [net-next] net: libwx: fix memory leak in wx_setup_rx_resources | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 18 this patch: 18
netdev/cc_maintainers success CCed 8 of 8 maintainers
netdev/build_clang success Errors and warnings before: 18 this patch: 18
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 18 this patch: 18
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 14 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

shaozhengchao April 18, 2023, 6:54 a.m. UTC
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(-)

Comments

Simon Horman April 19, 2023, 3:19 p.m. UTC | #1
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>
patchwork-bot+netdevbpf@kernel.org April 20, 2023, 2 p.m. UTC | #2
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!
diff mbox series

Patch

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;