drm/i915/gtt: Don't leak scratch page on mapping error
authorMika Kuoppala <mika.kuoppala@linux.intel.com>
Fri, 22 May 2015 17:04:58 +0000 (20:04 +0300)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Mon, 15 Jun 2015 10:12:42 +0000 (12:12 +0200)
Free the scratch page if dma mapping fails.

Signed-off-by: Mika Kuoppala <mika.kuoppala@intel.com>
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
drivers/gpu/drm/i915/i915_gem_gtt.c

index 619dad1b23863716972a23b12226b16af533a068..5e3bfa94221ba9b4e72696155dfa6420f01a1f72 100644 (file)
@@ -2143,8 +2143,10 @@ static int setup_scratch_page(struct drm_device *dev)
 #ifdef CONFIG_INTEL_IOMMU
        dma_addr = pci_map_page(dev->pdev, page, 0, PAGE_SIZE,
                                PCI_DMA_BIDIRECTIONAL);
-       if (pci_dma_mapping_error(dev->pdev, dma_addr))
+       if (pci_dma_mapping_error(dev->pdev, dma_addr)) {
+               __free_page(page);
                return -EINVAL;
+       }
 #else
        dma_addr = page_to_phys(page);
 #endif