From: wu000273@umn.edu
To: airlied@linux.ie
Cc: arnd@arndb.de, gregkh@linuxfoundation.org,
linux-kernel@vger.kernel.org, wu000273@umn.edu
Subject: [PATCH] drivers: fix a memory leak
Date: Thu, 7 Nov 2019 13:36:47 -0600 [thread overview]
Message-ID: <20191107193647.1944-1-wu000273@umn.edu> (raw)
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
next reply other threads:[~2019-11-07 19:45 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-07 19:36 wu000273 [this message]
2019-11-08 14:47 ` [PATCH] drivers: fix a memory leak Arnd Bergmann
2019-11-09 13:08 ` kbuild test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191107193647.1944-1-wu000273@umn.edu \
--to=wu000273@umn.edu \
--cc=airlied@linux.ie \
--cc=arnd@arndb.de \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).