Skip to content

Commit

Permalink
xtensa/platforms/iss/simdisk: add error handling support for add_disk()
Browse files Browse the repository at this point in the history
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 <mcgrof@kernel.org>
Acked-by: Max Filippov <jcmvbkbc@gmail.com>
Link: https://lore.kernel.org/r/20210927220110.1066271-7-mcgrof@kernel.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Luis Chamberlain authored and Jens Axboe committed Oct 18, 2021
1 parent 2f15107 commit db8eda9
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions arch/xtensa/platforms/iss/simdisk.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ static int __init simdisk_setup(struct simdisk *dev, int which,
struct proc_dir_entry *procdir)
{
char tmp[2] = { '0' + which, 0 };
int err = -ENOMEM;

dev->fd = -1;
dev->filename = NULL;
Expand All @@ -266,18 +267,26 @@ static int __init simdisk_setup(struct simdisk *dev, int which,

dev->gd = blk_alloc_disk(NUMA_NO_NODE);
if (!dev->gd)
return -ENOMEM;
goto out;
dev->gd->major = simdisk_major;
dev->gd->first_minor = which;
dev->gd->minors = SIMDISK_MINORS;
dev->gd->fops = &simdisk_ops;
dev->gd->private_data = dev;
snprintf(dev->gd->disk_name, 32, "simdisk%d", which);
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);

return 0;

out_cleanup_disk:
blk_cleanup_disk(dev->gd);
out:
return err;
}

static int __init simdisk_init(void)
Expand Down

0 comments on commit db8eda9

Please sign in to comment.