]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
virtio: Fix used_idx wrap-around
authorAnthony Liguori <aliguori@us.ibm.com>
Wed, 7 Nov 2007 21:49:24 +0000 (15:49 -0600)
committerRusty Russell <rusty@rustcorp.com.au>
Mon, 12 Nov 2007 02:59:09 +0000 (13:59 +1100)
The more_used() function compares the vq->vring.used->idx with last_used_idx.
Since vq->vring.used->idx is a 16-bit integer, and last_used_idx is an
unsigned int, this results in unpredictable behavior when vq->vring.used->idx
wraps around.

This patch corrects this by changing last_used_idx to the correct type.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
drivers/virtio/virtio_ring.c

index 0e4baca21b8f46e02f716a07aab4605e6663f20d..0e1bf053d8cd623c9e8246b118deb8e3fba12a62 100644 (file)
@@ -53,7 +53,7 @@ struct vring_virtqueue
        unsigned int num_added;
 
        /* Last used index we've seen. */
-       unsigned int last_used_idx;
+       u16 last_used_idx;
 
        /* How to notify other side. FIXME: commonalize hcalls! */
        void (*notify)(struct virtqueue *vq);