From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yong Wang Subject: [PATCH] eal/linux: fix fd check before close Date: Fri, 10 Feb 2017 08:53:17 -0500 Message-ID: <1486734797-24637-1-git-send-email-wang.yong19@zte.com.cn> Cc: dev@dpdk.org, Yong Wang To: ferruh.yigit@intel.com Return-path: Received: from mx5.zte.com.cn (mx5.zte.com.cn [63.217.80.70]) by dpdk.org (Postfix) with ESMTP id 4395C952 for ; Fri, 10 Feb 2017 13:43:19 +0100 (CET) List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The "dev->intr_handle.fd" is possibly a negative value while it is passed as an argument to function "close". Fix the check to the fd. Signed-off-by: Yong Wang --- lib/librte_eal/linuxapp/eal/eal_pci_uio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/librte_eal/linuxapp/eal/eal_pci_uio.c b/lib/librte_eal/linuxapp/eal/eal_pci_uio.c index 3e4ffb5..20a4a66 100644 --- a/lib/librte_eal/linuxapp/eal/eal_pci_uio.c +++ b/lib/librte_eal/linuxapp/eal/eal_pci_uio.c @@ -230,7 +230,7 @@ close(dev->intr_handle.uio_cfg_fd); dev->intr_handle.uio_cfg_fd = -1; } - if (dev->intr_handle.fd) { + if (dev->intr_handle.fd >= 0) { close(dev->intr_handle.fd); dev->intr_handle.fd = -1; dev->intr_handle.type = RTE_INTR_HANDLE_UNKNOWN; -- 1.8.3.1