From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>,
Stephen Hemminger <sthemmin@microsoft.com>
Subject: [dpdk-dev] [PATCH] bus/vmbus: fix resource leak on error
Date: Wed, 17 Apr 2019 11:45:06 -0700 [thread overview]
Message-ID: <20190417184506.18850-1-stephen@networkplumber.org> (raw)
Message-ID: <20190417184506.8L3KnH6OBAv99V-TrNw3kZrverFq-7VPO5TfN16tFiE@z> (raw)
If secondary process attempt to mmap the resource resulted in
the wrong address, then it would leave behind the bad mmap.
Coverity issue: 337675, 337664
Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>
---
drivers/bus/vmbus/linux/vmbus_uio.c | 4 +++-
drivers/bus/vmbus/vmbus_common_uio.c | 4 +++-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/bus/vmbus/linux/vmbus_uio.c b/drivers/bus/vmbus/linux/vmbus_uio.c
index fb60ee126d9b..be6b677f99d0 100644
--- a/drivers/bus/vmbus/linux/vmbus_uio.c
+++ b/drivers/bus/vmbus/linux/vmbus_uio.c
@@ -283,10 +283,12 @@ vmbus_uio_map_secondary_subchan(const struct rte_vmbus_device *dev,
if (mapaddr == MAP_FAILED)
VMBUS_LOG(ERR,
"mmap subchan %u in secondary failed", chan->relid);
- else
+ else {
VMBUS_LOG(ERR,
"mmap subchan %u in secondary address mismatch",
chan->relid);
+ vmbus_unmap_resource(mapaddr, 2 * ring_size);
+ }
return -1;
}
diff --git a/drivers/bus/vmbus/vmbus_common_uio.c b/drivers/bus/vmbus/vmbus_common_uio.c
index 1aa5cb2e4b92..8e476f2eaf8b 100644
--- a/drivers/bus/vmbus/vmbus_common_uio.c
+++ b/drivers/bus/vmbus/vmbus_common_uio.c
@@ -75,9 +75,11 @@ vmbus_uio_map_secondary(struct rte_vmbus_device *dev)
if (mapaddr == MAP_FAILED)
VMBUS_LOG(ERR,
"mmap resource %d in secondary failed", i);
- else
+ else {
VMBUS_LOG(ERR,
"mmap resource %d address mismatch", i);
+ vmbus_unmap_resource(mapaddr, uio_res->maps[i].size);
+ }
close(fd);
return -1;
--
2.20.1
next reply other threads:[~2019-04-17 18:45 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-17 18:45 Stephen Hemminger [this message]
2019-04-17 18:45 ` Stephen Hemminger
2019-04-22 12:43 ` Thomas Monjalon
2019-04-22 12:43 ` 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=20190417184506.18850-1-stephen@networkplumber.org \
--to=stephen@networkplumber.org \
--cc=dev@dpdk.org \
--cc=sthemmin@microsoft.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).