aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/virtio/virtio_ring.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/virtio/virtio_ring.c')
-rw-r--r--drivers/virtio/virtio_ring.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
index afe7e21dd0ae..1475ed6b575f 100644
--- a/drivers/virtio/virtio_ring.c
+++ b/drivers/virtio/virtio_ring.c
@@ -164,7 +164,8 @@ int virtqueue_add_buf_gfp(struct virtqueue *_vq,
164 gfp_t gfp) 164 gfp_t gfp)
165{ 165{
166 struct vring_virtqueue *vq = to_vvq(_vq); 166 struct vring_virtqueue *vq = to_vvq(_vq);
167 unsigned int i, avail, head, uninitialized_var(prev); 167 unsigned int i, avail, uninitialized_var(prev);
168 int head;
168 169
169 START_USE(vq); 170 START_USE(vq);
170 171
@@ -174,7 +175,7 @@ int virtqueue_add_buf_gfp(struct virtqueue *_vq,
174 * buffers, then go indirect. FIXME: tune this threshold */ 175 * buffers, then go indirect. FIXME: tune this threshold */
175 if (vq->indirect && (out + in) > 1 && vq->num_free) { 176 if (vq->indirect && (out + in) > 1 && vq->num_free) {
176 head = vring_add_indirect(vq, sg, out, in, gfp); 177 head = vring_add_indirect(vq, sg, out, in, gfp);
177 if (head != vq->vring.num) 178 if (likely(head >= 0))
178 goto add_head; 179 goto add_head;
179 } 180 }
180 181