From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37140) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bKrr9-0000m8-DA for qemu-devel@nongnu.org; Wed, 06 Jul 2016 14:47:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bKrr7-0000Pf-DU for qemu-devel@nongnu.org; Wed, 06 Jul 2016 14:47:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39505) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bKrr7-0000Pa-7L for qemu-devel@nongnu.org; Wed, 06 Jul 2016 14:47:29 -0400 From: marcandre.lureau@redhat.com Date: Wed, 6 Jul 2016 20:46:56 +0200 Message-Id: <20160706184721.2007-4-marcandre.lureau@redhat.com> In-Reply-To: <20160706184721.2007-1-marcandre.lureau@redhat.com> References: <20160706184721.2007-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH v3 03/28] vhost: don't assume opaque is a fd, use backend cleanup List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: mukawa@igel.co.jp, yuanhan.liu@linux.intel.com, victork@redhat.com, jonshin@cisco.com, mst@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau --- hw/virtio/vhost.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index a01394d..dbb4deb 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -997,21 +997,19 @@ int vhost_dev_init(struct vhost_dev *hdev, void *op= aque, =20 hdev->migration_blocker =3D NULL; =20 - if (vhost_set_backend_type(hdev, backend_type) < 0) { - close((uintptr_t)opaque); - return -1; - } + r =3D vhost_set_backend_type(hdev, backend_type); + assert(r >=3D 0); =20 - if (hdev->vhost_ops->vhost_backend_init(hdev, opaque) < 0) { - close((uintptr_t)opaque); - return -errno; + r =3D hdev->vhost_ops->vhost_backend_init(hdev, opaque); + if (r < 0) { + goto fail; } =20 if (used_memslots > hdev->vhost_ops->vhost_backend_memslots_limit(hd= ev)) { fprintf(stderr, "vhost backend memory slots limit is less" " than current number of present memory slots\n"); - close((uintptr_t)opaque); - return -1; + r =3D -1; + goto fail; } QLIST_INSERT_HEAD(&vhost_devices, hdev, entry); =20 --=20 2.9.0