mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-27 22:24:11 +08:00
virtio: Avoid possible kernel panic if DEBUG is enabled.
The virtqueue_add() calls START_USE() upon entry. The virtqueue_kick() is called if vq->num_added == (1 << 16) - 1 before calling END_USE(). The virtqueue_kick_prepare() called via virtqueue_kick() calls START_USE() upon entry, and will call panic() if DEBUG is enabled. Move this virtqueue_kick() call to after END_USE() call. Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
1862ee22ce
commit
5e05bf5833
@ -244,14 +244,14 @@ static inline int virtqueue_add(struct virtqueue *_vq,
|
|||||||
vq->vring.avail->idx = cpu_to_virtio16(_vq->vdev, virtio16_to_cpu(_vq->vdev, vq->vring.avail->idx) + 1);
|
vq->vring.avail->idx = cpu_to_virtio16(_vq->vdev, virtio16_to_cpu(_vq->vdev, vq->vring.avail->idx) + 1);
|
||||||
vq->num_added++;
|
vq->num_added++;
|
||||||
|
|
||||||
|
pr_debug("Added buffer head %i to %p\n", head, vq);
|
||||||
|
END_USE(vq);
|
||||||
|
|
||||||
/* This is very unlikely, but theoretically possible. Kick
|
/* This is very unlikely, but theoretically possible. Kick
|
||||||
* just in case. */
|
* just in case. */
|
||||||
if (unlikely(vq->num_added == (1 << 16) - 1))
|
if (unlikely(vq->num_added == (1 << 16) - 1))
|
||||||
virtqueue_kick(_vq);
|
virtqueue_kick(_vq);
|
||||||
|
|
||||||
pr_debug("Added buffer head %i to %p\n", head, vq);
|
|
||||||
END_USE(vq);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user