From patchwork Fri Feb 10 13:53:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yong Wang X-Patchwork-Id: 20374 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 2A16A9E7; Fri, 10 Feb 2017 13:43:23 +0100 (CET) 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) X-scanvirus: By SEG_CYREN AntiVirus Engine X-scanresult: CLEAN X-MAILFROM: X-RCPTTO: X-FROMIP: 10.30.3.20 X-SEG-Scaned: 1 X-Received: unknown,10.30.3.20,20170210203416 Received: from unknown (HELO mse01.zte.com.cn) (10.30.3.20) by localhost with (AES256-SHA encrypted) SMTP; 10 Feb 2017 12:34:16 -0000 Received: from notes_smtp.zte.com.cn ([10.30.1.239]) by mse01.zte.com.cn with ESMTP id v1ACh9cN005619; Fri, 10 Feb 2017 20:43:09 +0800 (GMT-8) (envelope-from wang.yong19@zte.com.cn) Received: from localhost.localdomain.localdomain ([10.43.166.165]) by szsmtp06.zte.com.cn (Lotus Domino Release 8.5.3FP6) with ESMTP id 2017021020431652-11574 ; Fri, 10 Feb 2017 20:43:16 +0800 From: Yong Wang To: ferruh.yigit@intel.com Cc: dev@dpdk.org, Yong Wang Date: Fri, 10 Feb 2017 08:53:17 -0500 Message-Id: <1486734797-24637-1-git-send-email-wang.yong19@zte.com.cn> X-Mailer: git-send-email 1.8.3.1 X-MIMETrack: Itemize by SMTP Server on SZSMTP06/server/zte_ltd(Release 8.5.3FP6|November 21, 2013) at 2017-02-10 20:43:16, Serialize by Router on notes_smtp/zte_ltd(Release 8.5.3FP6|November 21, 2013) at 2017-02-10 20:43:08, Serialize complete at 2017-02-10 20:43:08 X-MAIL: mse01.zte.com.cn v1ACh9cN005619 X-HQIP: 127.0.0.1 Subject: [dpdk-dev] [PATCH] eal/linux: fix fd check before close X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list 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;