From: Michael S. Tsirkin Date: Wed, 20 Jul 2011 10:41:31 +0000 (+0300) Subject: vhost-net: update used ring on backend change X-Git-Tag: upstream/snapshot3+hdmi~9624^2~1^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c047e5f3170c2595e66ed67f87cec01afd717212;p=platform%2Fadaptation%2Frenesas_rcar%2Frenesas_kernel.git vhost-net: update used ring on backend change 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 --- diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c index 70ac604..248b250 100644 --- a/drivers/vhost/net.c +++ b/drivers/vhost/net.c @@ -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);