From: Joerg Roedel Date: Tue, 29 Jan 2013 12:41:09 +0000 (+0100) Subject: iommu: Check for valid pgsize_bitmap in iommu_map/unmap X-Git-Tag: v3.9-rc1~73^2^2~3 X-Git-Url: http://pileus.org/git/?a=commitdiff_plain;h=57886518a8cdd319a04f5ea06a5f7ffcb8a93120;p=~andy%2Flinux iommu: Check for valid pgsize_bitmap in iommu_map/unmap In case the page-size bitmap is zero the code path in iommu_map and iommu_unmap is undefined. Make it defined and return -ENODEV in this case. Signed-off-by: Joerg Roedel --- diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 1065a1a1947..4e6d6f857e6 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -734,7 +734,8 @@ int iommu_map(struct iommu_domain *domain, unsigned long iova, size_t orig_size = size; int ret = 0; - if (unlikely(domain->ops->map == NULL)) + if (unlikely(domain->ops->unmap == NULL || + domain->ops->pgsize_bitmap == 0UL)) return -ENODEV; /* find out the minimum page size supported */ @@ -808,7 +809,8 @@ size_t iommu_unmap(struct iommu_domain *domain, unsigned long iova, size_t size) size_t unmapped_page, unmapped = 0; unsigned int min_pagesz; - if (unlikely(domain->ops->unmap == NULL)) + if (unlikely(domain->ops->unmap == NULL || + domain->ops->pgsize_bitmap == 0UL)) return -ENODEV; /* find out the minimum page size supported */