]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
iommu: Handle unmap error when iommu_debug is enabled
authorJason Gunthorpe <jgg@nvidia.com>
Tue, 12 May 2026 16:46:15 +0000 (13:46 -0300)
committerJoerg Roedel <joerg.roedel@amd.com>
Fri, 15 May 2026 05:29:16 +0000 (07:29 +0200)
commit0735c54804c709d1b292f3b6947cfb560b2ce552
tree0234d43ca5bb7d0b91744e7567a80ec90642183f
parentb948a87228482235afbaf5f4d8037860b5c470fd
iommu: Handle unmap error when iommu_debug is enabled

Sashiko noticed a latent bug where the map error flow called iommu_unmap()
which calls iommu_debug_unmap_begin()/iommu_debug_unmap_end() however
since this is an error path the map flow never actually established the
original iommu_debug_map() it will malfunction.

Lift the unmap error handling into iommu_map_nosync() and reorder it so
the trace_map()/iommu_debug_map() records the partial mapping and then
immediately unmaps it. This avoid creating the unbalanced tracking and
provides saner tracing instead of a unmap unmatched to any map.

Fixes: ccc21213f013 ("iommu: Add calls for IOMMU_DEBUG_PAGEALLOC")
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Reviewed-by: Pranjal Shrivastava <praan@google.com>
Reviewed-by: Samiullah Khawaja <skhawaja@google.com>
Reviewed-by: Mostafa Saleh <smostafa@google.com>
Tested-by: Josua Mayer <josua@solid-run.com>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
drivers/iommu/iommu.c