Skip to content

Commit 3ec6004

Browse files
rmurphy-armjoergroedel
authored andcommitted
iommu/dma: Don't put uninitialised IOVA domains
Due to the limitations of having to wait until we see a device's DMA restrictions before we know how we want an IOVA domain initialised, there is a window for error if a DMA ops domain is allocated but later freed without ever being used. In that case, init_iova_domain() was never called, so calling put_iova_domain() from iommu_put_dma_cookie() ends up trying to take an uninitialised lock and crashing. Make things robust by skipping the call unless the IOVA domain actually has been initialised, as we probably should have done from the start. Fixes: 0db2e5d ("iommu: Implement common IOMMU ops for DMA mapping") Cc: [email protected] Reported-by: Nate Watterson <[email protected]> Reviewed-by: Nate Watterson <[email protected]> Tested-by: Nate Watterson <[email protected]> Reviewed-by: Eric Auger <[email protected]> Tested-by: Eric Auger <[email protected]> Signed-off-by: Robin Murphy <[email protected]> Signed-off-by: Joerg Roedel <[email protected]>
1 parent 9a8a5dc commit 3ec6004

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/iommu/dma-iommu.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ void iommu_put_dma_cookie(struct iommu_domain *domain)
6868
if (!iovad)
6969
return;
7070

71-
put_iova_domain(iovad);
71+
if (iovad->granule)
72+
put_iova_domain(iovad);
7273
kfree(iovad);
7374
domain->iova_cookie = NULL;
7475
}

0 commit comments

Comments
 (0)