On Tue, Jul 25, 2023 at 04:05:48PM -0300, Jason Gunthorpe wrote: > The access must be detached first. > > To make the cleanup simpler copy the fdno to userspace before creating the > access in the first place. Then there is no need to unwind after > iommufd_access_attach. > > Fixes: 54b47585db66 ("iommufd: Create access in vfio_iommufd_emulated_bind()") > Signed-off-by: Jason Gunthorpe <jgg@xxxxxxxxxx> Hmm, I was expecting that the iopt_remove_access() call in the iommufd_access_destroy_object() could "detach" the access. If calling iopt_remove_access() isn't enough, it means that we'd need the full routine from the iommufd_access_detach() in cdev series, i.e. we are missing the unmap part? In that case, though this patch can fix the issue in selftest, yet does the emulated pathway potentially have the same issue? Thanks Nic