Skip to content

Commit b975abb

Browse files
QiushiWuickle
authored andcommitted
agp/intel: Fix a memory leak on module initialisation failure
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: 0e87d2b ("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
1 parent 2992b54 commit b975abb

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

‎drivers/char/agp/intel-gtt.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,10 @@ static int intel_gtt_setup_scratch_page(void)
304304
if (intel_private.needs_dmar) {
305305
dma_addr = pci_map_page(intel_private.pcidev, page, 0,
306306
PAGE_SIZE, PCI_DMA_BIDIRECTIONAL);
307-
if (pci_dma_mapping_error(intel_private.pcidev, dma_addr))
307+
if (pci_dma_mapping_error(intel_private.pcidev, dma_addr)) {
308+
__free_page(page);
308309
return -EINVAL;
310+
}
309311

310312
intel_private.scratch_page_dma = dma_addr;
311313
} else

0 commit comments

Comments
 (0)