Skip to content

Commit

Permalink
virtio: Fix vring_init/vring_size to take unsigned long
Browse files Browse the repository at this point in the history
Using unsigned int resulted in silent truncation of the upper 32-bit
on x86_64 resulting in an OOPS since the ring was being initialized
wrong.

Please reconsider my previous patch to just use PAGE_ALIGN().  Open
coding this sort of stuff, no matter how simple it seems, is just
asking for this sort of trouble.

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 Feb 4, 2008
1 parent f957d1f commit 3309daa
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 @@ -89,7 +89,7 @@ struct vring {
* };
*/
static inline void vring_init(struct vring *vr, unsigned int num, void *p,
unsigned int pagesize)
unsigned long pagesize)
{
vr->num = num;
vr->desc = p;
Expand All @@ -98,7 +98,7 @@ static inline void vring_init(struct vring *vr, unsigned int num, void *p,
& ~(pagesize - 1));
}

static inline unsigned vring_size(unsigned int num, unsigned int pagesize)
static inline unsigned vring_size(unsigned int num, unsigned long pagesize)
{
return ((sizeof(struct vring_desc) * num + sizeof(__u16) * (2 + num)
+ pagesize - 1) & ~(pagesize - 1))
Expand Down

0 comments on commit 3309daa

Please sign in to comment.