drm/i915/kvmgt: fix an error code in gvt_dma_map_page()
authorDan Carpenter <dan.carpenter@oracle.com>
Thu, 19 Jul 2018 08:19:21 +0000 (11:19 +0300)
committerZhenyu Wang <zhenyuw@linux.intel.com>
Tue, 7 Aug 2018 02:42:54 +0000 (10:42 +0800)
The dma_mapping_error() returns true on error but we want to return
-ENOMEM here.

Fixes: 79e542f5af79 ("drm/i915/kvmgt: Support setting dma map for huge pages")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Zhenyu Wang <zhenyuw@linux.intel.com>
drivers/gpu/drm/i915/gvt/kvmgt.c

index 4d2f53a..32ec574 100644 (file)
@@ -187,14 +187,14 @@ static int gvt_dma_map_page(struct intel_vgpu *vgpu, unsigned long gfn,
 
        /* Setup DMA mapping. */
        *dma_addr = dma_map_page(dev, page, 0, size, PCI_DMA_BIDIRECTIONAL);
-       ret = dma_mapping_error(dev, *dma_addr);
-       if (ret) {
+       if (dma_mapping_error(dev, *dma_addr)) {
                gvt_vgpu_err("DMA mapping failed for pfn 0x%lx, ret %d\n",
                             page_to_pfn(page), ret);
                gvt_unpin_guest_page(vgpu, gfn, size);
+               return -ENOMEM;
        }
 
-       return ret;
+       return 0;
 }
 
 static void gvt_dma_unmap_page(struct intel_vgpu *vgpu, unsigned long gfn,