[PATCH] net: lan969x: fix page pool leak when RX DMA allocation fails

Wentao Liang vulab at iscas.ac.cn
Tue Nov 3 02:28:54 PST 2026


lan969x_fdma_rx_alloc() creates the RX page pool and then allocates the
FDMA coherent memory. If fdma_alloc_coherent() fails, the function
returns without destroying the page pool.

The failure propagates out of lan969x_fdma_init(), and
sparx5_frame_io_init() then marks the FDMA IRQ as unavailable, so
lan969x_fdma_deinit() is never called on teardown and the page pool is
never released. Destroy it before returning the error.

Fixes: d84ad2c0d80c ("net: lan969x: add FDMA implementation")
Cc: stable at vger.kernel.org
Assisted-by: DeepSeek-V4.1-Flash and OpenAI Codex
Signed-off-by: Wentao Liang <vulab at iscas.ac.cn>
---
 drivers/net/ethernet/microchip/sparx5/lan969x/lan969x_fdma.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/microchip/sparx5/lan969x/lan969x_fdma.c b/drivers/net/ethernet/microchip/sparx5/lan969x/lan969x_fdma.c
index 053d125eda65..bc293ba1707d 100644
--- a/drivers/net/ethernet/microchip/sparx5/lan969x/lan969x_fdma.c
+++ b/drivers/net/ethernet/microchip/sparx5/lan969x/lan969x_fdma.c
@@ -169,8 +169,10 @@ static int lan969x_fdma_rx_alloc(struct sparx5 *sparx5)
 		return PTR_ERR(rx->page_pool);
 
 	err = fdma_alloc_coherent(sparx5->dev, fdma);
-	if (err)
+	if (err) {
+		page_pool_destroy(rx->page_pool);
 		return err;
+	}
 
 	fdma_dcbs_init(fdma,
 		       FDMA_DCB_INFO_DATAL(fdma->db_size),
-- 
2.34.1




More information about the linux-arm-kernel mailing list