From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id C066E1AEF3; Thu, 21 Sep 2017 15:49:31 +0200 (CEST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga105.fm.intel.com with ESMTP; 21 Sep 2017 06:49:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,425,1500966000"; d="scan'208";a="1221907420" Received: from unknown ([10.103.102.61]) by fmsmga002.fm.intel.com with SMTP; 21 Sep 2017 06:49:28 -0700 Received: by (sSMTP sendmail emulation); Thu, 21 Sep 2017 15:49:27 +0200 From: Michal Jastrzebski To: anatoly.burakov@intel.com Cc: dev@dpdk.org, deepak.k.jain@intel.com, Kuba Kozak , patrick@patrickmacarthur.net, stable@dpdk.org Date: Thu, 21 Sep 2017 15:49:08 +0200 Message-Id: <20170921134908.5076-1-michalx.k.jastrzebski@intel.com> X-Mailer: git-send-email 2.12.2 In-Reply-To: <1505901573-463-1-git-send-email-kubax.kozak@intel.com> References: <1505901573-463-1-git-send-email-kubax.kozak@intel.com> Subject: [dpdk-dev] [PATCH v2] 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: Thu, 21 Sep 2017 13:49:32 -0000 From: Kuba Kozak 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 Acked-by: Anatoly Burakov --- v2: Change check condition --- 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..537beeb 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 >= 0) + close(fd); break; case SOCKET_REQ_GROUP: /* wait for group number */ -- 2.7.4