public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] kvm tools: Fix virt_queue__set_used_elem
@ 2011-05-03 15:37 Sasha Levin
  2011-05-03 15:37 ` [PATCH 2/2] kvm tools: Protect from dup definitions in kernel header Sasha Levin
  2011-05-03 19:44 ` [PATCH 1/2] kvm tools: Fix virt_queue__set_used_elem Ingo Molnar
  0 siblings, 2 replies; 8+ messages in thread
From: Sasha Levin @ 2011-05-03 15:37 UTC (permalink / raw)
  To: penberg; +Cc: mingo, asias.hejun, gorcunov, prasadjoshi124, kvm, Sasha Levin

Increase idx only after updating the used element.
Not doing so may mark a buffer as used without having
it's head and length updated.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
---
 tools/kvm/virtio.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/tools/kvm/virtio.c b/tools/kvm/virtio.c
index 6249521..b2d2407 100644
--- a/tools/kvm/virtio.c
+++ b/tools/kvm/virtio.c
@@ -7,9 +7,10 @@
 struct vring_used_elem *virt_queue__set_used_elem(struct virt_queue *queue, uint32_t head, uint32_t len)
 {
 	struct vring_used_elem *used_elem;
-	used_elem	= &queue->vring.used->ring[queue->vring.used->idx++ % queue->vring.num];
+	used_elem	= &queue->vring.used->ring[queue->vring.used->idx % queue->vring.num];
 	used_elem->id	= head;
 	used_elem->len	= len;
+	queue->vring.used->idx++;
 	return used_elem;
 }
 
-- 
1.7.5.rc3


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2011-05-03 20:27 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-03 15:37 [PATCH 1/2] kvm tools: Fix virt_queue__set_used_elem Sasha Levin
2011-05-03 15:37 ` [PATCH 2/2] kvm tools: Protect from dup definitions in kernel header Sasha Levin
2011-05-03 19:49   ` Ingo Molnar
2011-05-03 19:56     ` Sasha Levin
2011-05-03 19:59       ` Ingo Molnar
2011-05-03 20:10         ` Cyrill Gorcunov
2011-05-03 20:27           ` Cyrill Gorcunov
2011-05-03 19:44 ` [PATCH 1/2] kvm tools: Fix virt_queue__set_used_elem Ingo Molnar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox