[lkml]   [2011]   [Apr]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[09/55] virtio: Decrement avail idx on buffer detach
2.6.38-stable review patch.  If anyone has any objections, please let us know.


From: Amit Shah <>

commit b3258ff1d6086bd2b9eeb556844a868ad7d49bc8 upstream.

When detaching a buffer from a vq, the avail.idx value should be
decremented as well.

This was noticed by hot-unplugging a virtio console port and then
plugging in a new one on the same number (re-using the vqs which were
just 'disowned'). qemu reported

'Guest moved used index from 0 to 256'

when any IO was attempted on the new port.

Reported-by: juzhang <>
Signed-off-by: Amit Shah <>
Signed-off-by: Rusty Russell <>
Signed-off-by: Greg Kroah-Hartman <>

drivers/virtio/virtio_ring.c | 1 +
1 file changed, 1 insertion(+)

--- a/drivers/virtio/virtio_ring.c
+++ b/drivers/virtio/virtio_ring.c
@@ -371,6 +371,7 @@ void *virtqueue_detach_unused_buf(struct
/* detach_buf clears data, so grab it now. */
buf = vq->data[i];
detach_buf(vq, i);
+ vq->vring.avail->idx--;
return buf;

 \ /
  Last update: 2011-04-29 21:01    [W:0.158 / U:7.672 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site