Re: [PATCH v4 02/18] PCI/P2PDMA: Wait for RCU readers before freeing state
Logan Gunthorpe <[email protected]>
| Newsgroups | org.kernel.vger.linux-pci,dev.linux.lists.iommu,org.kernel.vger.linux-doc,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
On 2026-08-21 13:38, Leon Romanovsky wrote: > From: Leon Romanovsky <[email protected]> > > 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 <[email protected]> > Cc: Alex Williamson <[email protected]> > Cc: Matt Evans <[email protected]> > Fixes: 372d6d1b8ae3 ("PCI/P2PDMA: Refactor to separate core P2P functionality from memory allocation") > Signed-off-by: Leon Romanovsky <[email protected]> Sounds fine: Reviewed-by: Logan Gunthorpe <[email protected]>