Re: [PATCH v5 net 2/4] net: hns3: fix page_pool leak in hns3_alloc_ring_memory error path
From: Simon Horman
Date: Wed Nov 25 2026 - 05:38:44 EST
On Wed, Nov 18, 2026 at 09:03:28PM +0800, Jijie Shao wrote:
> In hns3_alloc_ring_memory(), when hns3_alloc_ring_buffers() fails for
> an RX ring, the error path jumps to out_with_desc, which frees the
> descriptor ring but does not destroy the page_pool that was just
> allocated by hns3_alloc_page_pool(). The page_pool and its pages are
> leaked.
>
> Destroy the page_pool in that error path as well. The pool is torn down
> before the descriptor ring here, which is the opposite of the order in
> hns3_fini_ring(); that is safe because hns3_alloc_ring_buffers() has
> already detached every buffer it attached, so hns3_free_desc() walks
> descriptors whose dma is zero and never hands a page back to the pool.
>
> Fixes: 93188e9642c3 ("net: hns3: support skb's frag page recycling based on page pool")
> Signed-off-by: Jijie Shao <shaojijie@xxxxxxxxxx>
> ---
> Changes in v4:
> - Name hns3_fini_ring() instead of the non-existent
> hns3_free_ring_memory(), and drop "mirroring" because the destroy
> order differs. The pool is destroyed before the descriptor ring
> here, which is safe because hns3_alloc_ring_buffers() has already
> detached every buffer.
> v3: https://lore.kernel.org/all/20261030095633.377289-3-shaojijie@xxxxxxxxxx/
Reviewed-by: Simon Horman <horms@xxxxxxxxxx>