Re: [PATCH 01/13] PCI/P2PDMA: Release the per-cpu ref of pgmap when vm_insert_page() fails

From: Logan Gunthorpe

Date: Mon Dec 22 2025 - 11:50:10 EST




On 2025-12-19 21:04, Hou Tao wrote:
> From: Hou Tao <houtao1@xxxxxxxxxx>
>
> When vm_insert_page() fails in p2pmem_alloc_mmap(), p2pmem_alloc_mmap()
> doesn't invoke percpu_ref_put() to free the per-cpu ref of pgmap
> acquired after gen_pool_alloc_owner(), and memunmap_pages() will hang
> forever when trying to remove the PCIe device.
>
> Fix it by adding the missed percpu_ref_put().
>
> Fixes: 7e9c7ef83d78 ("PCI/P2PDMA: Allow userspace VMA allocations through sysfs")
> Signed-off-by: Hou Tao <houtao1@xxxxxxxxxx>
Nice catch, thanks:

Reviewed-by: Logan Gunthorpe <logang@xxxxxxxxxxxx>


Logan