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

Commit b7aab5e2 authored by Mitchel Humpherys's avatar Mitchel Humpherys Committed by Matt Wagantall
Browse files

dma-mapping: check for failed IOVA allocation



Currently if we fail to allocate an IOVA from our VA pool we proceed to
map DMA_ERROR_CODE into the IOMMU, which is not what the client
requested or expected.  Fix this by checking for an error return value
while allocating an IOVA and bailing out as appropriate.

Change-Id: I13df7b9ab52536b757d8ae0ca74a5b9e1e1438b5
Signed-off-by: default avatarMitchel Humpherys <mitchelh@codeaurora.org>
parent e2dddfa4
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -1150,6 +1150,11 @@ 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) {
		dev_err(dev, "Couldn't allocate iova for sg %p\n", sg);
		return 0;
	}

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