vhost: fix use after free
authorYuanhan Liu <yuanhan.liu@linux.intel.com>
Mon, 17 Apr 2017 07:27:04 +0000 (15:27 +0800)
committerYuanhan Liu <yuanhan.liu@linux.intel.com>
Wed, 19 Apr 2017 08:49:06 +0000 (10:49 +0200)
A "return" is missing on error, which could lead to a "use after free"
issue (about var "conn").

Coverity issue: 143476
Fixes: 65388b43f592 ("vhost: fix fd leaks for vhost-user server mode")

Reported-by: John McNamara <john.mcnamara@intel.com>
Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
lib/librte_vhost/socket.c

index 66fd335..c7f99b0 100644 (file)
@@ -242,6 +242,7 @@ vhost_user_add_connection(int fd, struct vhost_user_socket *vsocket)
                RTE_LOG(ERR, VHOST_CONFIG,
                        "failed to add fd %d into vhost server fdset\n",
                        fd);
+               return;
        }
 
        pthread_mutex_lock(&vsocket->conn_mutex);