From mboxrd@z Thu Jan 1 00:00:00 1970 From: Patrick MacArthur Subject: Re: [PATCH] vfio: fix close unchecked file descriptor Date: Wed, 20 Sep 2017 10:34:54 -0400 Message-ID: References: <1505901573-463-1-git-send-email-kubax.kozak@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Cc: dev@dpdk.org, stable@dpdk.org To: Kuba Kozak , anatoly.burakov@intel.com Return-path: In-Reply-To: <1505901573-463-1-git-send-email-kubax.kozak@intel.com> Content-Language: en-US List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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