Skip to content

Commit

Permalink
virtio: Fix used_idx wrap-around
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Anthony Liguori authored and Rusty Russell committed Nov 12, 2007
1 parent 4d125de commit 1bc4953
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/virtio/virtio_ring.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 1bc4953

Please sign in to comment.