Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

block/sunvdc: 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.

We re-use the same free tag call, so we also add a label for
that as well.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
Link: https://lore.kernel.org/r/20211103230437.1639990-9-mcgrof@kernel.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Luis Chamberlain and committed by
Jens Axboe
f583eaef 15733754

+11 -3
+11 -3
drivers/block/sunvdc.c
··· 826 826 if (IS_ERR(g)) { 827 827 printk(KERN_ERR PFX "%s: Could not allocate gendisk.\n", 828 828 port->vio.name); 829 - blk_mq_free_tag_set(&port->tag_set); 830 - return PTR_ERR(g); 829 + err = PTR_ERR(g); 830 + goto out_free_tag; 831 831 } 832 832 833 833 port->disk = g; ··· 879 879 port->vdisk_size, (port->vdisk_size >> (20 - 9)), 880 880 port->vio.ver.major, port->vio.ver.minor); 881 881 882 - device_add_disk(&port->vio.vdev->dev, g, NULL); 882 + err = device_add_disk(&port->vio.vdev->dev, g, NULL); 883 + if (err) 884 + goto out_cleanup_disk; 883 885 884 886 return 0; 887 + 888 + out_cleanup_disk: 889 + blk_cleanup_disk(g); 890 + out_free_tag: 891 + blk_mq_free_tag_set(&port->tag_set); 892 + return err; 885 893 } 886 894 887 895 static struct ldc_channel_config vdc_ldc_cfg = {