Skip to content

Commit f02b9ac

Browse files
shaohualiaxboe
authored andcommitted
virtio-blk: virtqueue_kick() must be ordered with other virtqueue operations
It isn't safe to call it without holding the vblk->vq_lock. Reported-by: Dave Chinner <david@fromorbit.com> Signed-off-by: Shaohua Li <shli@fusionio.com> Fixed another condition of virtqueue_kick() not holding the lock. Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 94eddfb commit f02b9ac

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

‎drivers/block/virtio_blk.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,15 +199,16 @@ static int virtio_queue_rq(struct blk_mq_hw_ctx *hctx, struct request *req)
199199

200200
spin_lock_irqsave(&vblk->vq_lock, flags);
201201
if (__virtblk_add_req(vblk->vq, vbr, vbr->sg, num) < 0) {
202+
virtqueue_kick(vblk->vq);
202203
spin_unlock_irqrestore(&vblk->vq_lock, flags);
203204
blk_mq_stop_hw_queue(hctx);
204-
virtqueue_kick(vblk->vq);
205205
return BLK_MQ_RQ_QUEUE_BUSY;
206206
}
207-
spin_unlock_irqrestore(&vblk->vq_lock, flags);
208207

209208
if (last)
210209
virtqueue_kick(vblk->vq);
210+
211+
spin_unlock_irqrestore(&vblk->vq_lock, flags);
211212
return BLK_MQ_RQ_QUEUE_OK;
212213
}
213214

0 commit comments

Comments
 (0)