[PATCH 2/2] drm/i915/gvt: use pfn_valid for better checking
Chuanxiao Dong
chuanxiao.dong at intel.com
Fri Feb 24 02:03:11 UTC 2017
Before get the page from pfn, use pfn_valid to check if pfn
is able to translate to page structure.
Signed-off-by: Chuanxiao Dong <chuanxiao.dong at intel.com>
---
drivers/gpu/drm/i915/gvt/kvmgt.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/i915/gvt/kvmgt.c b/drivers/gpu/drm/i915/gvt/kvmgt.c
index 4b5e88b..d12fc0d 100644
--- a/drivers/gpu/drm/i915/gvt/kvmgt.c
+++ b/drivers/gpu/drm/i915/gvt/kvmgt.c
@@ -96,10 +96,10 @@ static int gvt_dma_map_iova(struct intel_vgpu *vgpu, kvm_pfn_t pfn,
struct device *dev = &vgpu->gvt->dev_priv->drm.pdev->dev;
dma_addr_t daddr;
- page = pfn_to_page(pfn);
- if (is_error_page(page))
+ if (unlikely(!pfn_valid(pfn)))
return -EFAULT;
+ page = pfn_to_page(pfn);
daddr = dma_map_page(dev, page, 0, PAGE_SIZE,
DMA_BIDIRECTIONAL);
if (dma_mapping_error(dev, daddr))
--
2.7.4
More information about the intel-gvt-dev
mailing list