From: Jeff Dike <jdike@addtoit.com>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Xin Xiaohui <xiaohui.xin@intel.com>, LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH 1/2] vhost - Fix error path in vhost_net_set_backend
Date: Thu, 4 Mar 2010 16:10:14 -0500 [thread overview]
Message-ID: <20100304211014.GA10008@localhost.localdomain> (raw)
commit 7bee327f8020f81a52ecb362f1fec7a4494dc98b
Author: Jeff Dike <jdike@localhost.localdomain>
Date: Thu Mar 4 14:48:38 2010 -0500
Fix vhost_net_set_backend error path
An error could cause vhost_net_set_backend to exit without unlocking
vq->mutex.
Signed-off-by: Jeff Dike <jdike@linux.intel.com>
diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
index ad37da2..4ada4b4 100644
--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -508,12 +508,12 @@ static long vhost_net_set_backend(struct vhost_net *n, unsigned index, int fd)
/* Verify that ring has been setup correctly. */
if (!vhost_vq_access_ok(vq)) {
r = -EFAULT;
- goto err;
+ goto err_unlock_vq;
}
sock = get_socket(fd);
if (IS_ERR(sock)) {
r = PTR_ERR(sock);
- goto err;
+ goto err_unlock_vq;
}
/* start polling new socket */
@@ -524,12 +524,14 @@ static long vhost_net_set_backend(struct vhost_net *n, unsigned index, int fd)
vhost_net_disable_vq(n, vq);
rcu_assign_pointer(vq->private_data, sock);
vhost_net_enable_vq(n, vq);
- mutex_unlock(&vq->mutex);
done:
if (oldsock) {
vhost_net_flush_vq(n, index);
fput(oldsock->file);
}
+
+err_unlock_vq:
+ mutex_unlock(&vq->mutex);
err:
mutex_unlock(&n->dev.mutex);
return r;
next reply other threads:[~2010-03-04 21:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-04 21:10 Jeff Dike [this message]
2010-03-07 11:30 ` [PATCH 1/2] vhost - Fix error path in vhost_net_set_backend Michael S. Tsirkin
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=20100304211014.GA10008@localhost.localdomain \
--to=jdike@addtoit.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mst@redhat.com \
--cc=xiaohui.xin@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