Commit 21fd880d authored by Luis Chamberlain's avatar Luis Chamberlain Committed by Jens Axboe

m68k/emu/nfblock: 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.
Reviewed-by: default avatarGeert Uytterhoeven <geert@linux-m68k.org>
Acked-by: default avatarGeert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
Link: https://lore.kernel.org/r/20211015233028.2167651-7-mcgrof@kernel.orgSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 293a7c52
...@@ -99,6 +99,7 @@ static int __init nfhd_init_one(int id, u32 blocks, u32 bsize) ...@@ -99,6 +99,7 @@ static int __init nfhd_init_one(int id, u32 blocks, u32 bsize)
{ {
struct nfhd_device *dev; struct nfhd_device *dev;
int dev_id = id - NFHD_DEV_OFFSET; int dev_id = id - NFHD_DEV_OFFSET;
int err = -ENOMEM;
pr_info("nfhd%u: found device with %u blocks (%u bytes)\n", dev_id, pr_info("nfhd%u: found device with %u blocks (%u bytes)\n", dev_id,
blocks, bsize); blocks, bsize);
...@@ -129,16 +130,20 @@ static int __init nfhd_init_one(int id, u32 blocks, u32 bsize) ...@@ -129,16 +130,20 @@ static int __init nfhd_init_one(int id, u32 blocks, u32 bsize)
sprintf(dev->disk->disk_name, "nfhd%u", dev_id); sprintf(dev->disk->disk_name, "nfhd%u", dev_id);
set_capacity(dev->disk, (sector_t)blocks * (bsize / 512)); set_capacity(dev->disk, (sector_t)blocks * (bsize / 512));
blk_queue_logical_block_size(dev->disk->queue, bsize); blk_queue_logical_block_size(dev->disk->queue, bsize);
add_disk(dev->disk); err = add_disk(dev->disk);
if (err)
goto out_cleanup_disk;
list_add_tail(&dev->list, &nfhd_list); list_add_tail(&dev->list, &nfhd_list);
return 0; return 0;
out_cleanup_disk:
blk_cleanup_disk(dev->disk);
free_dev: free_dev:
kfree(dev); kfree(dev);
out: out:
return -ENOMEM; return err;
} }
static int __init nfhd_init(void) static int __init nfhd_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