Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0c2e37c9 authored by qqzhou's avatar qqzhou
Browse files

arm: dma-mapping: Add iova checks in arm_iommu_map_sg



In arm_iommu_map_sg(), will execute __alloc_iova() and
then use this returned iova to execute iommu_map_sg(),
when this iova is DMA_ERROR_CODE, the value is 0xffffffff,
pgsize will be zero and then issue happens.

For the DMA_ERROR_CODE iova value, should not be allowed
to map sg, add checks to avoid it.

Change-Id: Ic1620075080b88b4dbcff4f5a909dd8149b70507
Signed-off-by: default avatarQingqing Zhou <qqzhou@codeaurora.org>
parent 9b0f7eab
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -1965,6 +1965,8 @@ int arm_iommu_map_sg(struct device *dev, struct scatterlist *sg,
		total_length += s->length;

	iova = __alloc_iova(mapping, total_length);
	if (iova == DMA_ERROR_CODE)
		return 0;
	ret = iommu_map_sg(mapping->domain, iova, sg, nents, prot);
	if (ret != total_length) {
		__free_iova(mapping, iova, total_length);