diff options
author | Qiushi Wu <wu000273@umn.edu> | 2020-05-22 09:34:51 +0100 |
---|---|---|
committer | Lee Jones <lee.jones@linaro.org> | 2020-09-08 07:52:19 +0100 |
commit | cbc69f76239c0f0f0112512fb577165358a70286 (patch) | |
tree | f0ba3a66547028e9959c1b76fbba164b0ab2338a | |
parent | 5bdf318b4c6389123c3714e15b5e99f7587c962d (diff) |
agp/intel: Fix a memory leak on module initialisation failureASB-2020-09-05_3.18
[ Upstream commit b975abbd382fe442713a4c233549abb90e57c22b ]
In intel_gtt_setup_scratch_page(), pointer "page" is not released if
pci_dma_mapping_error() return an error, leading to a memory leak on
module initialisation failure. Simply fix this issue by freeing "page"
before return.
Fixes: 0e87d2b06cb46 ("intel-gtt: initialize our own scratch page")
Signed-off-by: Qiushi Wu <wu000273@umn.edu>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Link: https://patchwork.freedesktop.org/patch/msgid/20200522083451.7448-1-chris@chris-wilson.co.uk
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Change-Id: I74bad2aa0caac2fe37d090f78cc043a46b5abd61
-rw-r--r-- | drivers/char/agp/intel-gtt.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/char/agp/intel-gtt.c b/drivers/char/agp/intel-gtt.c index 9a99d0a3ff08..f8fa0059dcd0 100644 --- a/drivers/char/agp/intel-gtt.c +++ b/drivers/char/agp/intel-gtt.c @@ -306,8 +306,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 |