diff options
Diffstat (limited to 'drivers/virtio')
-rw-r--r-- | drivers/virtio/virtio_ring.c | 8 |
1 files changed, 7 insertions, 1 deletions
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; |