Skip to content

Commit 0fbea68

Browse files
ezequielgarciajoergroedel
authored andcommitted
iommu/dma: Fix leak in non-contiguous API
Currently, iommu_dma_alloc_noncontiguous() allocates a struct dma_sgt_handle object to hold some state needed for iommu_dma_free_noncontiguous(). However, the handle is neither freed nor returned explicitly by the ->alloc_noncontiguous method, and therefore seems leaked. This was found by code inspection, so please review carefully and test. As a side note, it appears the struct dma_sgt_handle type is exposed to users of the DMA-API by linux/dma-map-ops.h, but is has no users or functions returning the type explicitly. This may indicate it's a good idea to move the struct dma_sgt_handle type to drivers/iommu/dma-iommu.c. The decision is left to maintainers :-) Cc: [email protected] Fixes: e817ee5 ("dma-iommu: implement ->alloc_noncontiguous") Signed-off-by: Ezequiel Garcia <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Joerg Roedel <[email protected]>
1 parent ff11764 commit 0fbea68

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

drivers/iommu/dma-iommu.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -768,6 +768,7 @@ static void iommu_dma_free_noncontiguous(struct device *dev, size_t size,
768768
__iommu_dma_unmap(dev, sgt->sgl->dma_address, size);
769769
__iommu_dma_free_pages(sh->pages, PAGE_ALIGN(size) >> PAGE_SHIFT);
770770
sg_free_table(&sh->sgt);
771+
kfree(sh);
771772
}
772773
#endif /* CONFIG_DMA_REMAP */
773774

0 commit comments

Comments
 (0)