aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/vhost
diff options
context:
space:
mode:
authorJeff Dike <jdike@addtoit.com>2010-03-04 16:10:14 -0500
committerMichael S. Tsirkin <mst@redhat.com>2010-03-07 06:28:53 -0500
commit1dace8c801ac531022bd31a7316a6b4351837617 (patch)
tree4a2edd69b3fb495a5eaaf7426e8a49ad5a56f990 /drivers/vhost
parent39286fa41a8b2c6a9c1f656a7b3c3efca95bc1b9 (diff)
vhost: fix error path in vhost_net_set_backend
An error could cause vhost_net_set_backend to exit without unlocking vq->mutex. Fix this. Signed-off-by: Jeff Dike <jdike@linux.intel.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'drivers/vhost')
-rw-r--r--drivers/vhost/net.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
index ad37da2b6cb5..fcafb6b170fb 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)
508 /* Verify that ring has been setup correctly. */ 508 /* Verify that ring has been setup correctly. */
509 if (!vhost_vq_access_ok(vq)) { 509 if (!vhost_vq_access_ok(vq)) {
510 r = -EFAULT; 510 r = -EFAULT;
511 goto err; 511 goto err_vq;
512 } 512 }
513 sock = get_socket(fd); 513 sock = get_socket(fd);
514 if (IS_ERR(sock)) { 514 if (IS_ERR(sock)) {
515 r = PTR_ERR(sock); 515 r = PTR_ERR(sock);
516 goto err; 516 goto err_vq;
517 } 517 }
518 518
519 /* start polling new socket */ 519 /* start polling new socket */
@@ -524,12 +524,14 @@ static long vhost_net_set_backend(struct vhost_net *n, unsigned index, int fd)
524 vhost_net_disable_vq(n, vq); 524 vhost_net_disable_vq(n, vq);
525 rcu_assign_pointer(vq->private_data, sock); 525 rcu_assign_pointer(vq->private_data, sock);
526 vhost_net_enable_vq(n, vq); 526 vhost_net_enable_vq(n, vq);
527 mutex_unlock(&vq->mutex);
528done: 527done:
529 if (oldsock) { 528 if (oldsock) {
530 vhost_net_flush_vq(n, index); 529 vhost_net_flush_vq(n, index);
531 fput(oldsock->file); 530 fput(oldsock->file);
532 } 531 }
532
533err_vq:
534 mutex_unlock(&vq->mutex);
533err: 535err:
534 mutex_unlock(&n->dev.mutex); 536 mutex_unlock(&n->dev.mutex);
535 return r; 537 return r;