From: Omar Sandoval Date: Mon, 9 Jan 2017 19:44:12 +0000 (-0800) Subject: virtio_blk: fix panic in initialization error path X-Git-Tag: v4.9.42~11 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e6d53f5f8c0311032bf518d253522b73c96416f3;p=platform%2Fkernel%2Flinux-amlogic.git 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 Reviewed-by: Jeff Moyer Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c index 3c3b8f6..10332c2 100644 --- a/drivers/block/virtio_blk.c +++ b/drivers/block/virtio_blk.c @@ -630,11 +630,12 @@ static int virtblk_probe(struct virtio_device *vdev) if (err) 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)) { err = -ENOMEM; goto out_free_tags; } + vblk->disk->queue = q; q->queuedata = vblk;