Skip to content

Commit f583eae

Browse files
mcgrofaxboe
authored andcommitted
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 <[email protected]> Signed-off-by: Luis Chamberlain <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 1573375 commit f583eae

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

drivers/block/sunvdc.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -826,8 +826,8 @@ static int probe_disk(struct vdc_port *port)
826826
if (IS_ERR(g)) {
827827
printk(KERN_ERR PFX "%s: Could not allocate gendisk.\n",
828828
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;
831831
}
832832

833833
port->disk = g;
@@ -879,9 +879,17 @@ static int probe_disk(struct vdc_port *port)
879879
port->vdisk_size, (port->vdisk_size >> (20 - 9)),
880880
port->vio.ver.major, port->vio.ver.minor);
881881

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;
883885

884886
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;
885893
}
886894

887895
static struct ldc_channel_config vdc_ldc_cfg = {

0 commit comments

Comments
 (0)