summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlya Maximets <i.maximets@samsung.com>2018-11-23 18:39:19 +0300
committerThomas Monjalon <thomas@monjalon.net>2018-11-25 11:44:25 +0100
commit9e8b90fc6de98989583c9468769e5898bf6e9e0d (patch)
tree15975fe65e7a24980feb26b26003eeee2dc3ccca
parent8747682a69de45187f883107d29fedfc13554485 (diff)
downloaddpdk-9e8b90fc6de98989583c9468769e5898bf6e9e0d.zip
dpdk-9e8b90fc6de98989583c9468769e5898bf6e9e0d.tar.gz
dpdk-9e8b90fc6de98989583c9468769e5898bf6e9e0d.tar.xz
eal/bsd: fix possible IOPL fd leak
If rte_eal_iopl_init() will be called more than once we'll leak the file descriptor. Fixes: b46fe31862ec ("eal/bsd: fix virtio on FreeBSD") Cc: stable@dpdk.org Signed-off-by: Ilya Maximets <i.maximets@samsung.com> Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
-rw-r--r--lib/librte_eal/bsdapp/eal/eal.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c
index 508cbc4..b8152a7 100644
--- a/lib/librte_eal/bsdapp/eal/eal.c
+++ b/lib/librte_eal/bsdapp/eal/eal.c
@@ -556,9 +556,11 @@ int rte_eal_has_hugepages(void)
int
rte_eal_iopl_init(void)
{
- static int fd;
+ static int fd = -1;
+
+ if (fd < 0)
+ fd = open("/dev/io", O_RDWR);
- fd = open("/dev/io", O_RDWR);
if (fd < 0)
return -1;
/* keep fd open for iopl */