From: Roman Gushchin <klamm@yandex-team.ru>
To: dan.j.williams@intel.com, vinod.koul@intel.com,
dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] net_dma: fix memory leak in dma_pin_iocvec_pages
Date: Wed, 03 Sep 2014 13:28:59 +0400 [thread overview]
Message-ID: <87d2bdcask.wl%klamm@yandex-team.ru> (raw)
dma_pin_iovec_pages() calls get_user_pages() for each iovec. If
get_user_pages() returns a number smaller than the requested number,
dma_pin_iovec_pages() calls dma_unpin_iovec_pages(). It releases
previously allocated iovecs, but pages pinned by last get_user_pages()
call remain unreleased.
Fix this by calling put_page() for each such page.
Signed-off-by: Roman Gushchin <klamm@yandex-team.ru>
---
drivers/dma/iovlock.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/dma/iovlock.c b/drivers/dma/iovlock.c
index bb48a57..c393cf9 100644
--- a/drivers/dma/iovlock.c
+++ b/drivers/dma/iovlock.c
@@ -107,8 +107,11 @@ struct dma_pinned_list *dma_pin_iovec_pages(struct iovec *iov, size_t len)
NULL);
up_read(¤t->mm->mmap_sem);
- if (ret != page_list->nr_pages)
+ if (ret != page_list->nr_pages) {
+ for (i = 0; i < ret; i++)
+ put_page(page_list->pages[i]);
goto unpin;
+ }
local_list->nr_iovecs = i + 1;
}
--
1.9.3
next reply other threads:[~2014-09-03 9:38 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-03 9:28 Roman Gushchin [this message]
2014-09-19 12:04 ` Roman Gushchin
2014-09-24 4:57 ` Vinod Koul
2014-09-24 6:27 ` Dan Williams
2014-09-25 16:16 ` Vinod Koul
2014-09-28 15:36 ` Dan Williams
2014-09-28 15:25 ` Vinod Koul
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=87d2bdcask.wl%klamm@yandex-team.ru \
--to=klamm@yandex-team.ru \
--cc=dan.j.williams@intel.com \
--cc=dmaengine@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=vinod.koul@intel.com \
/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
Powered by JetHome