From: Ilya Maximets Date: Thu, 11 Apr 2019 10:23:06 +0000 (+0300) Subject: vhost: fix device leak on connection add failure X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=a21510e750430914a5638a8925e87609a32cbbff;p=dpdk.git vhost: fix device leak on connection add failure Need to destroy allocated device if application fails to add new connection or we have fdset failure. Fixes: acbff5c67ea7 ("vhost: fix crash when exceeding file descriptors") Fixes: efba12a78ddf ("vhost: add user callbacks for socket open/close") Cc: stable@dpdk.org Reported-by: David Marchand Signed-off-by: Ilya Maximets Reviewed-by: David Marchand Reviewed-by: Jens Freimann Reviewed-by: Tiwei Bie --- diff --git a/lib/librte_vhost/socket.c b/lib/librte_vhost/socket.c index 3da9de62c4..f0fdb83f7d 100644 --- a/lib/librte_vhost/socket.c +++ b/lib/librte_vhost/socket.c @@ -240,7 +240,7 @@ vhost_user_add_connection(int fd, struct vhost_user_socket *vsocket) RTE_LOG(ERR, VHOST_CONFIG, "failed to add vhost user connection with fd %d\n", fd); - goto err; + goto err_cleanup; } } @@ -257,7 +257,7 @@ vhost_user_add_connection(int fd, struct vhost_user_socket *vsocket) if (vsocket->notify_ops->destroy_connection) vsocket->notify_ops->destroy_connection(conn->vid); - goto err; + goto err_cleanup; } pthread_mutex_lock(&vsocket->conn_mutex); @@ -267,6 +267,8 @@ vhost_user_add_connection(int fd, struct vhost_user_socket *vsocket) fdset_pipe_notify(&vhost_user.fdset); return; +err_cleanup: + vhost_destroy_device(vid); err: free(conn); close(fd);