From: Tetsuya Mukawa <mukawa@igel.co.jp>
To: dev@dpdk.org
Cc: david.marchand@6wind.com, john.mcnamara@intel.com,
michalx.k.jastrzebski@intel.com,
Tetsuya Mukawa <mukawa@igel.co.jp>
Subject: [dpdk-dev] [PATCH v2] eal: Fix resource leak while secondary process maps pci devices
Date: Thu, 16 Jun 2016 11:33:11 +0900 [thread overview]
Message-ID: <1466044391-3210-3-git-send-email-mukawa@igel.co.jp> (raw)
In-Reply-To: <1466044391-3210-1-git-send-email-mukawa@igel.co.jp>
In-Reply-To: <1465961172-28253-1-git-send-email-mukawa@igel.co.jp>
This patch fixes resource leak of pci_uio_map_secondary().
If pci_map_resource() succeeds but mapped address is different from an
address primary process mapped, this should be error.
Then the addresses secondary process mapped should be freed.
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
---
lib/librte_eal/common/eal_common_pci_uio.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/lib/librte_eal/common/eal_common_pci_uio.c b/lib/librte_eal/common/eal_common_pci_uio.c
index 488b6dd..83314c3 100644
--- a/lib/librte_eal/common/eal_common_pci_uio.c
+++ b/lib/librte_eal/common/eal_common_pci_uio.c
@@ -53,7 +53,7 @@ EAL_REGISTER_TAILQ(rte_uio_tailq)
static int
pci_uio_map_secondary(struct rte_pci_device *dev)
{
- int fd, i;
+ int fd, i, j;
struct mapped_pci_resource *uio_res;
struct mapped_pci_res_list *uio_res_list =
RTE_TAILQ_CAST(rte_uio_tailq.head, mapped_pci_res_list);
@@ -85,6 +85,17 @@ pci_uio_map_secondary(struct rte_pci_device *dev)
"Cannot mmap device resource file %s to address: %p\n",
uio_res->maps[i].path,
uio_res->maps[i].addr);
+ if (mapaddr != MAP_FAILED) {
+ /* unmap addrs correctly mapped */
+ for (j = 0; j < i; j++)
+ pci_unmap_resource(
+ uio_res->maps[j].addr,
+ (size_t)uio_res->maps[j].size);
+
+ /* unmap addr wrongly mapped */
+ pci_unmap_resource(mapaddr,
+ (size_t)uio_res->maps[i].size);
+ }
return -1;
}
}
--
2.7.4
next prev parent reply other threads:[~2016-06-16 2:33 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-15 3:26 [dpdk-dev] [PATCH] eal: Fix wrong error checking of rte_eal_parse_devargs_str() Tetsuya Mukawa
2016-06-15 14:48 ` David Marchand
2016-06-16 2:03 ` Tetsuya Mukawa
2016-06-16 2:33 ` [dpdk-dev] [PATCH v2] eal: Fix wrong error checking while parsing device arguments Tetsuya Mukawa
2016-06-15 3:26 ` [dpdk-dev] [PATCH] eal: Fix resource leak of pci_uio_map_secondary() Tetsuya Mukawa
2016-06-15 14:45 ` David Marchand
2016-06-16 2:03 ` Tetsuya Mukawa
2016-06-16 2:33 ` Tetsuya Mukawa [this message]
2016-06-17 12:28 ` [dpdk-dev] [PATCH v2] eal: Fix resource leak while secondary process maps pci devices David Marchand
2016-06-20 2:19 ` Tetsuya Mukawa
2016-06-20 8:50 ` Thomas Monjalon
2016-06-15 3:27 ` [dpdk-dev] [PATCH] eal: Fix wrong resource release of pci_uio_unmap() Tetsuya Mukawa
2016-06-15 15:01 ` David Marchand
2016-06-16 2:33 ` [dpdk-dev] [PATCH v2] eal: Fix wrong resource release while unmapping pci devices Tetsuya Mukawa
2016-06-17 12:12 ` David Marchand
2016-06-20 8:50 ` Thomas Monjalon
2016-06-17 12:10 ` [dpdk-dev] [PATCH v2] eal: Fix wrong error checking while parsing device arguments David Marchand
2016-06-20 8:49 ` Thomas Monjalon
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=1466044391-3210-3-git-send-email-mukawa@igel.co.jp \
--to=mukawa@igel.co.jp \
--cc=david.marchand@6wind.com \
--cc=dev@dpdk.org \
--cc=john.mcnamara@intel.com \
--cc=michalx.k.jastrzebski@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;
as well as URLs for NNTP newsgroup(s).