mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joerg Roedel <joro@8bytes.org>
To: Sethi Varun-B16395 <B16395@freescale.com>
Cc: iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org,
	Joerg Roedel <joro@8bytes.org>
Subject: [PATCH 2/4] iommu: Check for valid pgsize_bitmap in iommu_map/unmap
Date: Wed, 30 Jan 2013 22:43:46 +0100	[thread overview]
Message-ID: <1359582228-21552-3-git-send-email-joro@8bytes.org> (raw)
In-Reply-To: <1359582228-21552-1-git-send-email-joro@8bytes.org>

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 |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index ddbdaca..622360f 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 */
-- 
1.7.9.5



  parent reply	other threads:[~2013-01-30 21:44 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-30 21:43 [PATCH 0/4] iommu: Support non-paging IOMMUs Joerg Roedel
2013-01-30 21:43 ` [PATCH 1/4] iommu: Make sure DOMAIN_ATTR_MAX is really the maximum Joerg Roedel
2013-01-30 21:43 ` Joerg Roedel [this message]
2013-01-30 21:43 ` [PATCH 3/4] iommu: Implement DOMAIN_ATTR_PAGING attribute Joerg Roedel
2013-01-30 21:43 ` [PATCH 4/4] iommu: Add domain window handling functions Joerg Roedel
2013-01-31  9:32   ` Sethi Varun-B16395
2013-02-04 13:02     ` Joerg Roedel
2013-02-04 23:36       ` Scott Wood
2013-02-05  3:41         ` Yoder Stuart-B08248

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1359582228-21552-3-git-send-email-joro@8bytes.org \
    --to=joro@8bytes.org \
    --cc=B16395@freescale.com \
    --cc=iommu@lists.linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®