From: Kuba Kozak Date: Thu, 21 Sep 2017 13:49:08 +0000 (+0200) Subject: vfio: fix close unchecked file descriptor X-Git-Tag: spdx-start~2130 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=96128b365eff2a1e5477e676c08c1fc631cc82c2;p=dpdk.git vfio: fix close unchecked file descriptor Add file descriptor value check before calling close() function. Coverity issue: 141297 Fixes: 811b6b25060f ("vfio: fix file descriptor leak in multi-process") Cc: stable@dpdk.org Signed-off-by: Kuba Kozak Acked-by: Anatoly Burakov Acked-by: Patrick MacArthur --- 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 7e8095cbaf..537beebd49 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 */