Skip to content

Commit 874f226

Browse files
osandovgregkh
authored andcommitted
virtio_blk: fix panic in initialization error path
[ Upstream commit 6bf6b0aa3da84a3d9126919a94c49c0fb7ee2fb3 ] If blk_mq_init_queue() returns an error, it gets assigned to vblk->disk->queue. Then, when we call put_disk(), we end up calling blk_put_queue() with the ERR_PTR, causing a bad dereference. Fix it by only assigning to vblk->disk->queue on success. Signed-off-by: Omar Sandoval <osandov@fb.com> Reviewed-by: Jeff Moyer <jmoyer@redhat.com> Signed-off-by: Jens Axboe <axboe@fb.com> Signed-off-by: Sasha Levin <alexander.levin@verizon.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent c9e4ee4 commit 874f226

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

drivers/block/virtio_blk.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -641,11 +641,12 @@ static int virtblk_probe(struct virtio_device *vdev)
641641
if (err)
642642
goto out_put_disk;
643643

644-
q = vblk->disk->queue = blk_mq_init_queue(&vblk->tag_set);
644+
q = blk_mq_init_queue(&vblk->tag_set);
645645
if (IS_ERR(q)) {
646646
err = -ENOMEM;
647647
goto out_free_tags;
648648
}
649+
vblk->disk->queue = q;
649650

650651
q->queuedata = vblk;
651652

0 commit comments

Comments
 (0)