[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20200522053915.4396-1-wu000273@umn.edu>
Date: Fri, 22 May 2020 00:39:15 -0500
From: wu000273@....edu
To: airlied@...ux.ie
Cc: arnd@...db.de, gregkh@...uxfoundation.org,
linux-kernel@...r.kernel.org, kjlu@....edu, wu000273@....edu
Subject: [PATCH] drm/i915: fix a memory leak bug.
From: Qiushi Wu <wu000273@....edu>
In intel_gtt_setup_scratch_page(), pointer "page" is not released if
pci_dma_mapping_error() return an error, leading to a memory leak bug.
Fix this issue by freeing "page" before return.
Fixes: 0e87d2b06cb46 ("intel-gtt: initialize our own scratch page")
Signed-off-by: Qiushi Wu <wu000273@....edu>
---
drivers/char/agp/intel-gtt.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/char/agp/intel-gtt.c b/drivers/char/agp/intel-gtt.c
index 66a62d17a3f5..a56a50f2740f 100644
--- a/drivers/char/agp/intel-gtt.c
+++ b/drivers/char/agp/intel-gtt.c
@@ -304,8 +304,10 @@ static int intel_gtt_setup_scratch_page(void)
if (intel_private.needs_dmar) {
dma_addr = pci_map_page(intel_private.pcidev, page, 0,
PAGE_SIZE, PCI_DMA_BIDIRECTIONAL);
- if (pci_dma_mapping_error(intel_private.pcidev, dma_addr))
+ if (pci_dma_mapping_error(intel_private.pcidev, dma_addr)) {
+ __free_page(page);
return -EINVAL;
+ }
intel_private.scratch_page_dma = dma_addr;
} else
--
2.17.1
Powered by blists - more mailing lists