Re: [PATCH v4 02/18] PCI/P2PDMA: Wait for RCU readers before freeing state
From: Logan Gunthorpe
Date: Fri Aug 21 2026 - 19:10:52 EST
On 2026-08-21 13:38, Leon Romanovsky wrote:
> From: Leon Romanovsky <leonro@xxxxxxxxxx>
>
> pci_p2pmem_find_many() scans all PCI devices without locking or
> protection against driver unbind, including devices with poolless
> P2PDMA state. pci_has_p2pmem() may observe pdev->p2pdma just before
> driver unbind clears it, while pci_p2pdma_release() skips the grace
> period when no pool is present. This allows devres to free the object
> while it is still in use.
>
> Clear the pointer with RCU_INIT_POINTER() and always wait for pre-existing
> RCU readers before returning. The same grace period continues to protect
> gen_pool users for pool-backed providers.
>
> Tested-by: Tushar Dave <tdave@xxxxxxxxxx>
> Cc: Alex Williamson <alex@xxxxxxxxxxx>
> Cc: Matt Evans <matt@xxxxxxxxxx>
> Fixes: 372d6d1b8ae3 ("PCI/P2PDMA: Refactor to separate core P2P functionality from memory allocation")
> Signed-off-by: Leon Romanovsky <leonro@xxxxxxxxxx>
Sounds fine:
Reviewed-by: Logan Gunthorpe <logang@xxxxxxxxxxxx>