Skip to content

Commit

Permalink
virtio: fix vring_init for 64 bits
Browse files Browse the repository at this point in the history
This patch fixes a typo in vring_init().  This happens to work today in lguest
because the sizeof(struct vring_desc) is 16 and struct vring contains 3
pointers and an unsigned int so on 32-bit
sizeof(struct vring_desc) == sizeof(struct vring).  However, this is no longer
true on 64-bit where the bug is exposed.

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 rustyrussell committed Nov 12, 2007
1 parent 6e800af commit 44332f7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions include/linux/virtio_ring.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ static inline void vring_init(struct vring *vr, unsigned int num, void *p)
{
vr->num = num;
vr->desc = p;
vr->avail = p + num*sizeof(struct vring);
vr->used = p + (num+1)*(sizeof(struct vring) + sizeof(__u16));
vr->avail = p + num*sizeof(struct vring_desc);
vr->used = p + (num+1)*(sizeof(struct vring_desc) + sizeof(__u16));
}

static inline unsigned vring_size(unsigned int num)
Expand Down

0 comments on commit 44332f7

Please sign in to comment.