Skip to content

Commit

Permalink
vhost-net: update used ring on backend change
Browse files Browse the repository at this point in the history
On backend change, we flushed out outstanding skbs
but forgot to update the used ring, so that
done entries were left in the ubuf_info ring.
As a result we lose heads or complete incorrect ones,
crashing the guest or leaking memory.
Fix by updating the used ring.

Signed-off-by: Michael S. Tsirkin <[email protected]>
  • Loading branch information
mstsirkin committed Jul 21, 2011
1 parent b834226 commit c047e5f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion drivers/vhost/net.c
Original file line number Diff line number Diff line change
Expand Up @@ -711,8 +711,12 @@ static long vhost_net_set_backend(struct vhost_net *n, unsigned index, int fd)

mutex_unlock(&vq->mutex);

if (oldubufs)
if (oldubufs) {
vhost_ubuf_put_and_wait(oldubufs);
mutex_lock(&vq->mutex);
vhost_zerocopy_signal_used(vq);
mutex_unlock(&vq->mutex);
}

if (oldsock) {
vhost_net_flush_vq(n, index);
Expand Down

0 comments on commit c047e5f

Please sign in to comment.