lkml.org 
[lkml]   [2019]   [Nov]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] drivers: fix a memory leak
Date
From: Qiushi Wu <wu000273@umn.edu>

In intel_gtt_setup_scratch_page(), "page" is not released if
pci_dma_mapping_error() return errors. This will lead to memory leak.
Fix this issue by freeing "page" before return.

Signed-off-by: Qiushi Wu <wu000273@umn.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 c6271ce250b3..bd38b179157c 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_pages(page);
return -EINVAL;
+ }

intel_private.scratch_page_dma = dma_addr;
} else
--
2.17.1
\
 
 \ /
  Last update: 2019-11-07 20:46    [W:0.034 / U:37.844 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site