From patchwork Wed Sep 20 09:59:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuba Kozak X-Patchwork-Id: 28996 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C878025B3; Wed, 20 Sep 2017 12:01:52 +0200 (CEST) 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 --- 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 */