From: Shaohua Li Date: Wed, 20 Nov 2013 01:57:24 +0000 (-0700) Subject: virtio-blk: virtqueue_kick() must be ordered with other virtqueue operations X-Git-Tag: upstream/snapshot3+hdmi~3919^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f02b9ac35a47dff745c7637fbc095f01cc03646e;hp=94eddfbeaafa3e8040a2c47d370dea0e58e76941;p=platform%2Fadaptation%2Frenesas_rcar%2Frenesas_kernel.git 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 Signed-off-by: Shaohua Li Fixed another condition of virtqueue_kick() not holding the lock. Signed-off-by: Jens Axboe --- diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c index 588479d..6a680d4 100644 --- a/drivers/block/virtio_blk.c +++ b/drivers/block/virtio_blk.c @@ -199,15 +199,16 @@ static int virtio_queue_rq(struct blk_mq_hw_ctx *hctx, struct request *req) spin_lock_irqsave(&vblk->vq_lock, flags); if (__virtblk_add_req(vblk->vq, vbr, vbr->sg, num) < 0) { + virtqueue_kick(vblk->vq); spin_unlock_irqrestore(&vblk->vq_lock, flags); blk_mq_stop_hw_queue(hctx); - virtqueue_kick(vblk->vq); return BLK_MQ_RQ_QUEUE_BUSY; } - spin_unlock_irqrestore(&vblk->vq_lock, flags); if (last) virtqueue_kick(vblk->vq); + + spin_unlock_irqrestore(&vblk->vq_lock, flags); return BLK_MQ_RQ_QUEUE_OK; }