Commit 57886518 authored by Joerg Roedel's avatar Joerg Roedel

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: default avatarJoerg Roedel <joro@8bytes.org>
parent a8b8a88a
...@@ -734,7 +734,8 @@ int iommu_map(struct iommu_domain *domain, unsigned long iova, ...@@ -734,7 +734,8 @@ int iommu_map(struct iommu_domain *domain, unsigned long iova,
size_t orig_size = size; size_t orig_size = size;
int ret = 0; int ret = 0;
if (unlikely(domain->ops->map == NULL)) if (unlikely(domain->ops->unmap == NULL ||
domain->ops->pgsize_bitmap == 0UL))
return -ENODEV; return -ENODEV;
/* find out the minimum page size supported */ /* 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) ...@@ -808,7 +809,8 @@ size_t iommu_unmap(struct iommu_domain *domain, unsigned long iova, size_t size)
size_t unmapped_page, unmapped = 0; size_t unmapped_page, unmapped = 0;
unsigned int min_pagesz; unsigned int min_pagesz;
if (unlikely(domain->ops->unmap == NULL)) if (unlikely(domain->ops->unmap == NULL ||
domain->ops->pgsize_bitmap == 0UL))
return -ENODEV; return -ENODEV;
/* find out the minimum page size supported */ /* find out the minimum page size supported */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment