Skip to content

Commit

Permalink
iommu: Check for valid pgsize_bitmap in iommu_map/unmap
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Joerg Roedel committed Feb 6, 2013
1 parent a8b8a88 commit 5788651
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions drivers/iommu/iommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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 */
Expand Down

0 comments on commit 5788651

Please sign in to comment.