From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id 0D5B0239; Wed, 20 Sep 2017 12:01:50 +0200 (CEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga104.jf.intel.com with ESMTP; 20 Sep 2017 03:01:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,420,1500966000"; d="scan'208";a="137443390" Received: from unknown (HELO Sent) ([10.103.102.91]) by orsmga002.jf.intel.com with SMTP; 20 Sep 2017 03:01:46 -0700 Received: by Sent (sSMTP sendmail emulation); Wed, 20 Sep 2017 11:59:35 +0200 From: Kuba Kozak To: anatoly.burakov@intel.com Cc: dev@dpdk.org, Kuba Kozak , patrick@patrickmacarthur.net, stable@dpdk.org Date: Wed, 20 Sep 2017 11:59:33 +0200 Message-Id: <1505901573-463-1-git-send-email-kubax.kozak@intel.com> X-Mailer: git-send-email 2.7.4 Subject: [dpdk-dev] [PATCH] vfio: fix close unchecked file descriptor 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: , X-List-Received-Date: Wed, 20 Sep 2017 10:01:51 -0000 Add file descriptor value check before calling close() function. Coverity issue: 141297 Fixes: 811b6b25060f ("vfio: fix file descriptor leak in multi-process") Cc: patrick@patrickmacarthur.net Cc: stable@dpdk.org Signed-off-by: Kuba Kozak --- lib/librte_eal/linuxapp/eal/eal_vfio_mp_sync.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/librte_eal/linuxapp/eal/eal_vfio_mp_sync.c b/lib/librte_eal/linuxapp/eal/eal_vfio_mp_sync.c index 7e8095c..c04f548 100644 --- a/lib/librte_eal/linuxapp/eal/eal_vfio_mp_sync.c +++ b/lib/librte_eal/linuxapp/eal/eal_vfio_mp_sync.c @@ -301,7 +301,8 @@ vfio_mp_sync_thread(void __rte_unused * arg) vfio_mp_sync_send_request(conn_sock, SOCKET_ERR); else vfio_mp_sync_send_fd(conn_sock, fd); - close(fd); + if (fd != -1) + close(fd); break; case SOCKET_REQ_GROUP: /* wait for group number */ -- 2.7.4