vfio: fix close unchecked file descriptor
authorKuba Kozak <kubax.kozak@intel.com>
Thu, 21 Sep 2017 13:49:08 +0000 (15:49 +0200)
committerThomas Monjalon <thomas@monjalon.net>
Thu, 5 Oct 2017 21:41:42 +0000 (23:41 +0200)
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 <kubax.kozak@intel.com>
Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
Acked-by: Patrick MacArthur <patrick@patrickmacarthur.net>
lib/librte_eal/linuxapp/eal/eal_vfio_mp_sync.c

index 7e8095c..537beeb 100644 (file)
@@ -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 */