From: Ilya Maximets Date: Fri, 23 Nov 2018 15:39:19 +0000 (+0300) Subject: eal/bsd: fix possible IOPL fd leak X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=9e8b90fc6de98989583c9468769e5898bf6e9e0d;p=dpdk.git 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 Reviewed-by: Maxime Coquelin --- diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c index 508cbc46fd..b8152a75cd 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 */