Skip to content

Commit 1680e90

Browse files
committed
vhost-net: avoid flush under lock
We flush under vq mutex when changing backends. This creates a deadlock as workqueue being flushed needs this lock as well. https://bugzilla.redhat.com/show_bug.cgi?id=612421 Drop the vq mutex before flush: we have the device mutex which is sufficient to prevent another ioctl from touching the vq. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
1 parent 7b3384f commit 1680e90

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

‎drivers/vhost/net.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,11 +534,16 @@ static long vhost_net_set_backend(struct vhost_net *n, unsigned index, int fd)
534534
rcu_assign_pointer(vq->private_data, sock);
535535
vhost_net_enable_vq(n, vq);
536536
done:
537+
mutex_unlock(&vq->mutex);
538+
537539
if (oldsock) {
538540
vhost_net_flush_vq(n, index);
539541
fput(oldsock->file);
540542
}
541543

544+
mutex_unlock(&n->dev.mutex);
545+
return 0;
546+
542547
err_vq:
543548
mutex_unlock(&vq->mutex);
544549
err:

0 commit comments

Comments
 (0)