Commit db8eda9c authored by Luis Chamberlain's avatar Luis Chamberlain Committed by Jens Axboe

xtensa/platforms/iss/simdisk: 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: default avatarLuis Chamberlain <mcgrof@kernel.org>
Acked-by: default avatarMax Filippov <jcmvbkbc@gmail.com>
Link: https://lore.kernel.org/r/20210927220110.1066271-7-mcgrof@kernel.orgSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 2f151070
...@@ -258,6 +258,7 @@ static int __init simdisk_setup(struct simdisk *dev, int which, ...@@ -258,6 +258,7 @@ static int __init simdisk_setup(struct simdisk *dev, int which,
struct proc_dir_entry *procdir) struct proc_dir_entry *procdir)
{ {
char tmp[2] = { '0' + which, 0 }; char tmp[2] = { '0' + which, 0 };
int err = -ENOMEM;
dev->fd = -1; dev->fd = -1;
dev->filename = NULL; dev->filename = NULL;
...@@ -266,7 +267,7 @@ static int __init simdisk_setup(struct simdisk *dev, int which, ...@@ -266,7 +267,7 @@ static int __init simdisk_setup(struct simdisk *dev, int which,
dev->gd = blk_alloc_disk(NUMA_NO_NODE); dev->gd = blk_alloc_disk(NUMA_NO_NODE);
if (!dev->gd) if (!dev->gd)
return -ENOMEM; goto out;
dev->gd->major = simdisk_major; dev->gd->major = simdisk_major;
dev->gd->first_minor = which; dev->gd->first_minor = which;
dev->gd->minors = SIMDISK_MINORS; dev->gd->minors = SIMDISK_MINORS;
...@@ -274,10 +275,18 @@ static int __init simdisk_setup(struct simdisk *dev, int which, ...@@ -274,10 +275,18 @@ static int __init simdisk_setup(struct simdisk *dev, int which,
dev->gd->private_data = dev; dev->gd->private_data = dev;
snprintf(dev->gd->disk_name, 32, "simdisk%d", which); snprintf(dev->gd->disk_name, 32, "simdisk%d", which);
set_capacity(dev->gd, 0); set_capacity(dev->gd, 0);
add_disk(dev->gd); err = add_disk(dev->gd);
if (err)
goto out_cleanup_disk;
dev->procfile = proc_create_data(tmp, 0644, procdir, &simdisk_proc_ops, dev); dev->procfile = proc_create_data(tmp, 0644, procdir, &simdisk_proc_ops, dev);
return 0; return 0;
out_cleanup_disk:
blk_cleanup_disk(dev->gd);
out:
return err;
} }
static int __init simdisk_init(void) static int __init simdisk_init(void)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment