diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/lguest/lguest_device.c | 3 | ||||
-rw-r--r-- | drivers/virtio/virtio_ring.c | 8 |
2 files changed, 9 insertions, 2 deletions
diff --git a/drivers/lguest/lguest_device.c b/drivers/lguest/lguest_device.c index 8904f72f97c6..66f38722253a 100644 --- a/drivers/lguest/lguest_device.c +++ b/drivers/lguest/lguest_device.c | |||
@@ -200,7 +200,8 @@ static struct virtqueue *lg_find_vq(struct virtio_device *vdev, | |||
200 | 200 | ||
201 | /* Figure out how many pages the ring will take, and map that memory */ | 201 | /* Figure out how many pages the ring will take, and map that memory */ |
202 | lvq->pages = lguest_map((unsigned long)lvq->config.pfn << PAGE_SHIFT, | 202 | lvq->pages = lguest_map((unsigned long)lvq->config.pfn << PAGE_SHIFT, |
203 | DIV_ROUND_UP(vring_size(lvq->config.num), | 203 | DIV_ROUND_UP(vring_size(lvq->config.num, |
204 | PAGE_SIZE), | ||
204 | PAGE_SIZE)); | 205 | PAGE_SIZE)); |
205 | if (!lvq->pages) { | 206 | if (!lvq->pages) { |
206 | err = -ENOMEM; | 207 | err = -ENOMEM; |
diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c index 0e1bf053d8cd..1dc04b6684e6 100644 --- a/drivers/virtio/virtio_ring.c +++ b/drivers/virtio/virtio_ring.c | |||
@@ -277,11 +277,17 @@ struct virtqueue *vring_new_virtqueue(unsigned int num, | |||
277 | struct vring_virtqueue *vq; | 277 | struct vring_virtqueue *vq; |
278 | unsigned int i; | 278 | unsigned int i; |
279 | 279 | ||
280 | /* We assume num is a power of 2. */ | ||
281 | if (num & (num - 1)) { | ||
282 | dev_warn(&vdev->dev, "Bad virtqueue length %u\n", num); | ||
283 | return NULL; | ||
284 | } | ||
285 | |||
280 | vq = kmalloc(sizeof(*vq) + sizeof(void *)*num, GFP_KERNEL); | 286 | vq = kmalloc(sizeof(*vq) + sizeof(void *)*num, GFP_KERNEL); |
281 | if (!vq) | 287 | if (!vq) |
282 | return NULL; | 288 | return NULL; |
283 | 289 | ||
284 | vring_init(&vq->vring, num, pages); | 290 | vring_init(&vq->vring, num, pages, PAGE_SIZE); |
285 | vq->vq.callback = callback; | 291 | vq->vq.callback = callback; |
286 | vq->vq.vdev = vdev; | 292 | vq->vq.vdev = vdev; |
287 | vq->vq.vq_ops = &vring_vq_ops; | 293 | vq->vq.vq_ops = &vring_vq_ops; |