mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-06 10:00:17 +00:00
iommu/dma: Don't put uninitialised IOVA domains
commit3ec60043f7upstream. 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:0db2e5d18f("iommu: Implement common IOMMU ops for DMA mapping") Reported-by: Nate Watterson <nwatters@codeaurora.org> Reviewed-by: Nate Watterson <nwatters@codeaurora.org> Tested-by: Nate Watterson <nwatters@codeaurora.org> Reviewed-by: Eric Auger <eric.auger@redhat.com> Tested-by: Eric Auger <eric.auger@redhat.com> Signed-off-by: Robin Murphy <robin.murphy@arm.com> Signed-off-by: Joerg Roedel <jroedel@suse.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
433ccf1fb4
commit
d360081c4b
@@ -68,6 +68,7 @@ void iommu_put_dma_cookie(struct iommu_domain *domain)
|
||||
if (!iovad)
|
||||
return;
|
||||
|
||||
if (iovad->granule)
|
||||
put_iova_domain(iovad);
|
||||
kfree(iovad);
|
||||
domain->iova_cookie = NULL;
|
||||
|
||||
Reference in New Issue
Block a user