Skip to content

Commit 076344a

Browse files
devnexenPaolo Abeni
authored andcommitted
net: lan966x: fix page pool leak in error paths
lan966x_fdma_rx_alloc() creates a page pool but does not destroy it if the subsequent fdma_alloc_coherent() call fails, leaking the pool. Similarly, lan966x_fdma_init() frees the coherent DMA memory when lan966x_fdma_tx_alloc() fails but does not destroy the page pool that was successfully created by lan966x_fdma_rx_alloc(), leaking it. Add the missing page_pool_destroy() calls in both error paths. Fixes: 11871ab ("net: lan96x: Use page_pool API") Cc: stable@vger.kernel.org Signed-off-by: David Carlier <devnexen@gmail.com> Link: https://patch.msgid.link/20260405055241.35767-3-devnexen@gmail.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent 3fd0da4 commit 076344a

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,10 @@ static int lan966x_fdma_rx_alloc(struct lan966x_rx *rx)
119119
return PTR_ERR(rx->page_pool);
120120

121121
err = fdma_alloc_coherent(lan966x->dev, fdma);
122-
if (err)
122+
if (err) {
123+
page_pool_destroy(rx->page_pool);
123124
return err;
125+
}
124126

125127
fdma_dcbs_init(fdma, FDMA_DCB_INFO_DATAL(fdma->db_size),
126128
FDMA_DCB_STATUS_INTR);
@@ -957,6 +959,7 @@ int lan966x_fdma_init(struct lan966x *lan966x)
957959
err = lan966x_fdma_tx_alloc(&lan966x->tx);
958960
if (err) {
959961
fdma_free_coherent(lan966x->dev, &lan966x->rx.fdma);
962+
page_pool_destroy(lan966x->rx.page_pool);
960963
return err;
961964
}
962965

0 commit comments

Comments
 (0)