From: Mika Kuoppala Date: Fri, 22 May 2015 17:04:58 +0000 (+0300) Subject: drm/i915/gtt: Don't leak scratch page on mapping error X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=ea3f5d261fb0b757f95c1657f71ac86eb1778fd1;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git drm/i915/gtt: Don't leak scratch page on mapping error Free the scratch page if dma mapping fails. Signed-off-by: Mika Kuoppala Reviewed-by: Joonas Lahtinen Signed-off-by: Daniel Vetter --- diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c index 619dad1b2386..5e3bfa94221b 100644 --- a/drivers/gpu/drm/i915/i915_gem_gtt.c +++ b/drivers/gpu/drm/i915/i915_gem_gtt.c @@ -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