Commit c6ff489c authored by Qiushi Wu's avatar Qiushi Wu Committed by Kelsey Skunberg

agp/intel: Fix a memory leak on module initialisation failure

BugLink: https://bugs.launchpad.net/bugs/1892822

[ Upstream commit b975abbd ]

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: 0e87d2b0 ("intel-gtt: initialize our own scratch page")
Signed-off-by: default avatarQiushi Wu <wu000273@umn.edu>
Reviewed-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Link: https://patchwork.freedesktop.org/patch/msgid/20200522083451.7448-1-chris@chris-wilson.co.ukSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarKhalid Elmously <khalid.elmously@canonical.com>
Signed-off-by: default avatarIan May <ian.may@canonical.com>
Signed-off-by: default avatarKelsey Skunberg <kelsey.skunberg@canonical.com>
parent a8ab69b2
...@@ -303,8 +303,10 @@ static int intel_gtt_setup_scratch_page(void) ...@@ -303,8 +303,10 @@ static int intel_gtt_setup_scratch_page(void)
if (intel_private.needs_dmar) { if (intel_private.needs_dmar) {
dma_addr = pci_map_page(intel_private.pcidev, page, 0, dma_addr = pci_map_page(intel_private.pcidev, page, 0,
PAGE_SIZE, PCI_DMA_BIDIRECTIONAL); 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; return -EINVAL;
}
intel_private.scratch_page_dma = dma_addr; intel_private.scratch_page_dma = dma_addr;
} else } else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment