[RFC PATCH 02/15] virtio-blk: Handle virtio_device_ready() failure
From: Xie Yongji
Date: Mon May 17 2021 - 05:35:09 EST
Now virtio_device_ready() will return error if we get
invalid status. Let's handle this case in both probe
and resume paths.
Signed-off-by: Xie Yongji <xieyongji@xxxxxxxxxxxxx>
---
drivers/block/virtio_blk.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
index 255adb7a768c..ebb4d3fe803f 100644
--- a/drivers/block/virtio_blk.c
+++ b/drivers/block/virtio_blk.c
@@ -884,11 +884,15 @@ static int virtblk_probe(struct virtio_device *vdev)
}
virtblk_update_capacity(vblk, false);
- virtio_device_ready(vdev);
+ err = virtio_device_ready(vdev);
+ if (err)
+ goto out_cleanup_queue;
device_add_disk(&vdev->dev, vblk->disk, virtblk_attr_groups);
return 0;
+out_cleanup_queue:
+ blk_cleanup_queue(vblk->disk->queue);
out_free_tags:
blk_mq_free_tag_set(&vblk->tag_set);
out_put_disk:
@@ -961,7 +965,12 @@ static int virtblk_restore(struct virtio_device *vdev)
if (ret)
return ret;
- virtio_device_ready(vdev);
+ ret = virtio_device_ready(vdev);
+ if (ret) {
+ vdev->config->del_vqs(vdev);
+ kfree(vblk->vqs);
+ return ret;
+ }
blk_mq_unquiesce_queue(vblk->disk->queue);
return 0;
--
2.11.0