]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
net: lan966x: fix page pool leak in error paths
authorDavid Carlier <devnexen@gmail.com>
Sun, 5 Apr 2026 05:52:40 +0000 (06:52 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 18 Apr 2026 08:46:46 +0000 (10:46 +0200)
commit 076344a6ad9d1308faaed1402fdcfdda68b604ab upstream.

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: 11871aba1974 ("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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c

index 1b898f57ec7bfeef2de102b110e954dfbfdb2579..e5d88e098fbba05a7ad7c6f65048019e57bfbd4f 100644 (file)
@@ -119,8 +119,10 @@ static int lan966x_fdma_rx_alloc(struct lan966x_rx *rx)
                return PTR_ERR(rx->page_pool);
 
        err = fdma_alloc_coherent(lan966x->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),
                       FDMA_DCB_STATUS_INTR);
@@ -958,6 +960,7 @@ int lan966x_fdma_init(struct lan966x *lan966x)
        err = lan966x_fdma_tx_alloc(&lan966x->tx);
        if (err) {
                fdma_free_coherent(lan966x->dev, &lan966x->rx.fdma);
+               page_pool_destroy(lan966x->rx.page_pool);
                return err;
        }