DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ilya Maximets <i.maximets@samsung.com>
To: dev@dpdk.org, Maxime Coquelin <maxime.coquelin@redhat.com>
Cc: Tiwei Bie <tiwei.bie@intel.com>,
	Jens Freimann <jfreimann@redhat.com>,
	Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>,
	David Marchand <david.marchand@redhat.com>,
	Ilya Maximets <i.maximets@samsung.com>,
	stable@dpdk.org
Subject: [dpdk-dev] [PATCH] vhost: fix device leak on connection add failure
Date: Thu, 11 Apr 2019 13:23:06 +0300	[thread overview]
Message-ID: <20190411102306.11943-1-i.maximets@samsung.com> (raw)
In-Reply-To: <CGME20190411102312eucas1p2c52abee0af4079ca87c8bb8af7b16274@eucas1p2.samsung.com>

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 <david.marchand@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
---
 lib/librte_vhost/socket.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/librte_vhost/socket.c b/lib/librte_vhost/socket.c
index 43f091d10..c34668004 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);
-- 
2.17.1

       reply	other threads:[~2019-04-11 10:23 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20190411102312eucas1p2c52abee0af4079ca87c8bb8af7b16274@eucas1p2.samsung.com>
2019-04-11 10:23 ` Ilya Maximets [this message]
2019-04-11 10:23   ` Ilya Maximets
2019-04-11 14:06   ` David Marchand
2019-04-11 14:06     ` David Marchand
2019-04-11 14:30   ` Jens Freimann
2019-04-11 14:30     ` Jens Freimann
2019-04-15  6:32   ` Tiwei Bie
2019-04-15  6:32     ` Tiwei Bie
2019-04-17  7:55   ` Maxime Coquelin
2019-04-17  7:55     ` Maxime Coquelin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190411102306.11943-1-i.maximets@samsung.com \
    --to=i.maximets@samsung.com \
    --cc=dariuszx.stojaczyk@intel.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=jfreimann@redhat.com \
    --cc=maxime.coquelin@redhat.com \
    --cc=stable@dpdk.org \
    --cc=tiwei.bie@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).