From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from plateau.patrickmacarthur.net (plateau.patrickmacarthur.net [174.138.60.243]) by dpdk.org (Postfix) with ESMTP id BFD26101B; Wed, 20 Sep 2017 16:35:01 +0200 (CEST) Received: from [132.177.127.174] (gtp127174.iol.unh.edu [132.177.127.174]) by plateau.patrickmacarthur.net (Postfix) with ESMTPSA id CDE91BE613; Wed, 20 Sep 2017 14:34:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=patrickmacarthur.net; s=mail; t=1505918094; bh=mvhKx8jd/LZiXkawMu/eT5acIRcYpYb6ILOu8Ts4EcY=; h=Subject:To:Cc:References:From:Date:In-Reply-To; b=qQoarsHB2oawQuAt25I0dpYiOpifFWD3xPsIYhKY+gsIOnGqJ++8p7bH1lOJlH/Jb NPuS11ssPzs2fK39yec+ibdbOQeUoFKd5HQwBGjqsSICFbyaWIxfXpxcj52ZJzhEtW ay6yWU1spzQGtToo8z1N1e5SlWPkK8WxSVJjr7WY= To: Kuba Kozak , anatoly.burakov@intel.com Cc: dev@dpdk.org, stable@dpdk.org References: <1505901573-463-1-git-send-email-kubax.kozak@intel.com> From: Patrick MacArthur Message-ID: Date: Wed, 20 Sep 2017 10:34:54 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <1505901573-463-1-git-send-email-kubax.kozak@intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.1 required=5.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on plateau.patrickmacarthur.net Subject: Re: [dpdk-stable] [PATCH] vfio: fix close unchecked file descriptor X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Sep 2017 14:35:01 -0000 On 09/20/2017 05:59 AM, Kuba Kozak wrote: > 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); IMHO this should be: if (fd >= 0) What specifically is Coverity complaining about here? Is there a specific code path that leads to fd being -1 here? Thanks, Patrick MacArthur