提交 6bf6b0aa 编写于 作者: O Omar Sandoval 提交者: Jens Axboe

virtio_blk: fix panic in initialization error path

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: NOmar Sandoval <osandov@fb.com>
Reviewed-by: NJeff Moyer <jmoyer@redhat.com>
Signed-off-by: NJens Axboe <axboe@fb.com>
上级 25b4acfc
...@@ -630,11 +630,12 @@ static int virtblk_probe(struct virtio_device *vdev) ...@@ -630,11 +630,12 @@ static int virtblk_probe(struct virtio_device *vdev)
if (err) if (err)
goto out_put_disk; goto out_put_disk;
q = vblk->disk->queue = blk_mq_init_queue(&vblk->tag_set); q = blk_mq_init_queue(&vblk->tag_set);
if (IS_ERR(q)) { if (IS_ERR(q)) {
err = -ENOMEM; err = -ENOMEM;
goto out_free_tags; goto out_free_tags;
} }
vblk->disk->queue = q;
q->queuedata = vblk; q->queuedata = vblk;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册