From: Luis Chamberlain Date: Wed, 18 Aug 2021 14:45:41 +0000 (+0200) Subject: virtio_blk: add error handling support for add_disk() X-Git-Tag: v5.15~460^2~15 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=dbb301f91fc855dccf9bc42fbc4281d89365906d;p=platform%2Fkernel%2Flinux-starfive.git virtio_blk: add error handling support for add_disk() We never checked for errors on add_disk() as this function returned void. Now that this is fixed, use the shiny new error handling. Signed-off-by: Luis Chamberlain Reviewed-by: Hannes Reinecke Link: https://lore.kernel.org/r/20210818144542.19305-11-hch@lst.de Signed-off-by: Jens Axboe --- diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c index 767b4f7..63dc121 100644 --- a/drivers/block/virtio_blk.c +++ b/drivers/block/virtio_blk.c @@ -875,9 +875,14 @@ static int virtblk_probe(struct virtio_device *vdev) virtblk_update_capacity(vblk, false); virtio_device_ready(vdev); - device_add_disk(&vdev->dev, vblk->disk, virtblk_attr_groups); + err = device_add_disk(&vdev->dev, vblk->disk, virtblk_attr_groups); + if (err) + goto out_cleanup_disk; + return 0; +out_cleanup_disk: + blk_cleanup_disk(vblk->disk); out_free_tags: blk_mq_free_tag_set(&vblk->tag_set); out_free_vq: