]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
iommu: Check for valid pgsize_bitmap in iommu_map/unmap
authorJoerg Roedel <joro@8bytes.org>
Tue, 29 Jan 2013 12:41:09 +0000 (13:41 +0100)
committerJoerg Roedel <joro@8bytes.org>
Wed, 6 Feb 2013 09:47:05 +0000 (10:47 +0100)
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 <joro@8bytes.org>
drivers/iommu/iommu.c

index 1065a1a1947831e9e47f55c83250a5d0aaf1a16e..4e6d6f857e6fcd2c1fbccb4953eafa8f57b8632f 100644 (file)
@@ -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 */