From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: stable@dpdk.org, Stephen Hemminger <sthemmin@microsoft.com>
Subject: [dpdk-dev] [PATCH 3/7] bus/vmbus: fix check for mmap failure
Date: Thu, 7 Feb 2019 19:44:03 -0800 [thread overview]
Message-ID: <20190208034407.7865-4-stephen@networkplumber.org> (raw)
In-Reply-To: <20190208034407.7865-1-stephen@networkplumber.org>
From: Stephen Hemminger <sthemmin@microsoft.com>
The code was testing the result of mmap incorrectly.
I.e the test that a local pointer is not MAP_FAILED would
always succeed and therefore hid any potential problems.
Fixes: 831dba47bd36 ("bus/vmbus: add Hyper-V virtual bus support")
Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>
---
drivers/bus/vmbus/linux/vmbus_uio.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/drivers/bus/vmbus/linux/vmbus_uio.c b/drivers/bus/vmbus/linux/vmbus_uio.c
index 09f7efdca286..8c6bc52fd475 100644
--- a/drivers/bus/vmbus/linux/vmbus_uio.c
+++ b/drivers/bus/vmbus/linux/vmbus_uio.c
@@ -202,6 +202,7 @@ static int vmbus_uio_map_subchan(const struct rte_vmbus_device *dev,
char ring_path[PATH_MAX];
size_t file_size;
struct stat sb;
+ void *mapaddr;
int fd;
snprintf(ring_path, sizeof(ring_path),
@@ -232,14 +233,16 @@ static int vmbus_uio_map_subchan(const struct rte_vmbus_device *dev,
return -EINVAL;
}
- *ring_size = file_size / 2;
- *ring_buf = vmbus_map_resource(vmbus_map_addr, fd,
- 0, sb.st_size, 0);
+ mapaddr = vmbus_map_resource(vmbus_map_addr, fd,
+ 0, file_size, 0);
close(fd);
- if (ring_buf == MAP_FAILED)
+ if (mapaddr == MAP_FAILED)
return -EIO;
+ *ring_size = file_size / 2;
+ *ring_buf = mapaddr;
+
vmbus_map_addr = RTE_PTR_ADD(ring_buf, file_size);
return 0;
}
--
2.20.1
next prev parent reply other threads:[~2019-02-08 3:44 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-08 3:44 [dpdk-dev] [PATCH 0/7] vmbus/netvsc: fix multi-process support Stephen Hemminger
2019-02-08 3:44 ` [dpdk-dev] [PATCH 1/7] bus/vmbus: fix secondary process setup Stephen Hemminger
2019-02-08 3:44 ` [dpdk-dev] [PATCH 2/7] net/netvsc: fix VF support with secondary process Stephen Hemminger
2019-02-08 3:44 ` Stephen Hemminger [this message]
2019-02-08 3:44 ` [dpdk-dev] [PATCH 4/7] bus/vmbus: stop mapping if empty resource found Stephen Hemminger
2019-02-08 3:44 ` [dpdk-dev] [PATCH 5/7] bus/vmbus: map ring in secondary Stephen Hemminger
2019-02-08 3:44 ` [dpdk-dev] [PATCH 6/7] bus/vmbus: refactor secondary mapping Stephen Hemminger
2019-02-08 3:44 ` [dpdk-dev] [PATCH 7/7] net/netvsc: remove unnecessary format of ether address Stephen Hemminger
2019-03-29 9:51 ` [dpdk-dev] [dpdk-stable] [PATCH 0/7] vmbus/netvsc: fix multi-process support Thomas Monjalon
2019-03-29 9:51 ` 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=20190208034407.7865-4-stephen@networkplumber.org \
--to=stephen@networkplumber.org \
--cc=dev@dpdk.org \
--cc=stable@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).