提交 3b870624 编写于 作者: A Amit Shah 提交者: Rusty Russell

virtio: Initialize vq->data entries to NULL

vq operations depend on vq->data[i] being NULL to figure out if the vq
entry is in use (since the previous patch).

We have to initialize them to NULL to ensure we don't work with junk
data and trigger false BUG_ONs.
Signed-off-by: NAmit Shah <amit.shah@redhat.com>
Signed-off-by: NRusty Russell <rusty@rustcorp.com.au>
Cc: Shirley Ma <xma@us.ibm.com>
上级 c021eac4
...@@ -448,8 +448,11 @@ struct virtqueue *vring_new_virtqueue(unsigned int num, ...@@ -448,8 +448,11 @@ struct virtqueue *vring_new_virtqueue(unsigned int num,
/* Put everything in free lists. */ /* Put everything in free lists. */
vq->num_free = num; vq->num_free = num;
vq->free_head = 0; vq->free_head = 0;
for (i = 0; i < num-1; i++) for (i = 0; i < num-1; i++) {
vq->vring.desc[i].next = i+1; vq->vring.desc[i].next = i+1;
vq->data[i] = NULL;
}
vq->data[i] = NULL;
return &vq->vq; return &vq->vq;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册