mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
To: iommu@lists.linux-foundation.org, kvm@vger.kernel.org,
	linux-kernel@vger.kernel.org
Cc: joro@8bytes.org, jroedel@suse.de, alex.williamson@redhat.com,
	Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
Subject: [PATCH 2/2] vfio/type1: Add iommu_unmap error check when vfio_unmap_unpin
Date: Tue, 30 Jan 2018 20:48:05 -0500	[thread overview]
Message-ID: <1517363285-89304-3-git-send-email-suravee.suthikulpanit@amd.com> (raw)
In-Reply-To: <1517363285-89304-1-git-send-email-suravee.suthikulpanit@amd.com>

Besides zero check the number of unmapped page, also check
and handle iommu_unmap errors.

Cc: Alex Williamson <alex.williamson@redhat.com>
Cc: Joerg Roedel <joro@8bytes.org>
Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
---
 drivers/vfio/vfio_iommu_type1.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c
index e30e29a..c580518 100644
--- a/drivers/vfio/vfio_iommu_type1.c
+++ b/drivers/vfio/vfio_iommu_type1.c
@@ -677,7 +677,8 @@ static long vfio_unmap_unpin(struct vfio_iommu *iommu, struct vfio_dma *dma,
 	}
 
 	while (iova < end) {
-		size_t unmapped, len;
+		ssize_t unmapped;
+		size_t len;
 		phys_addr_t phys, next;
 
 		phys = iommu_iova_to_phys(domain->domain, iova);
@@ -699,7 +700,7 @@ static long vfio_unmap_unpin(struct vfio_iommu *iommu, struct vfio_dma *dma,
 		}
 
 		unmapped = iommu_unmap(domain->domain, iova, len);
-		if (WARN_ON(!unmapped))
+		if (WARN_ON(unmapped <= 0))
 			break;
 
 		unlocked += vfio_unpin_pages_remote(dma, iova,
-- 
1.8.3.1

      parent reply	other threads:[~2018-01-31  1:48 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-31  1:48 [PATCH 0/2] iommu / vfio: Clean up iommu_map[_fast] interface Suravee Suthikulpanit
2018-01-31  1:48 ` [PATCH 1/2] iommu: Fix iommu_unmap and iommu_unmap_fast return type Suravee Suthikulpanit
2018-01-31 18:02   ` Robin Murphy
2018-02-01  5:03     ` Suravee Suthikulpanit
2018-02-01 12:17       ` Robin Murphy
2018-02-02 19:13   ` kbuild test robot
2018-02-02 19:41   ` kbuild test robot
2018-02-02 23:57   ` kbuild test robot
2018-01-31  1:48 ` Suravee Suthikulpanit [this message]

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=1517363285-89304-3-git-send-email-suravee.suthikulpanit@amd.com \
    --to=suravee.suthikulpanit@amd.com \
    --cc=alex.williamson@redhat.com \
    --cc=iommu@lists.linux-foundation.org \
    --cc=joro@8bytes.org \
    --cc=jroedel@suse.de \
    --cc=kvm@vger.kernel.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®