summaryrefslogtreecommitdiff
path: root/drivers/block/n64cart.c
diff options
context:
space:
mode:
authorLuis Chamberlain <mcgrof@kernel.org>2021-09-27 15:01:02 -0700
committerJens Axboe <axboe@kernel.dk>2021-10-18 14:41:36 -0600
commitd1df6021b70ce7823df89941c0c97e746fa2ad92 (patch)
treeab17a2b32b46ad56ca31e98be27ef5ac61b45163 /drivers/block/n64cart.c
parente92ab4eda516a5bfd96c087282ebe9521deba4f4 (diff)
n64cart: 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: Luis Chamberlain <mcgrof@kernel.org> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'drivers/block/n64cart.c')
-rw-r--r--drivers/block/n64cart.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/drivers/block/n64cart.c b/drivers/block/n64cart.c
index b168ca25b6c9..78282f01f581 100644
--- a/drivers/block/n64cart.c
+++ b/drivers/block/n64cart.c
@@ -115,6 +115,7 @@ static const struct block_device_operations n64cart_fops = {
static int __init n64cart_probe(struct platform_device *pdev)
{
struct gendisk *disk;
+ int err = -ENOMEM;
if (!start || !size) {
pr_err("start or size not specified\n");
@@ -132,7 +133,7 @@ static int __init n64cart_probe(struct platform_device *pdev)
disk = blk_alloc_disk(NUMA_NO_NODE);
if (!disk)
- return -ENOMEM;
+ goto out;
disk->first_minor = 0;
disk->flags = GENHD_FL_NO_PART_SCAN;
@@ -147,11 +148,18 @@ static int __init n64cart_probe(struct platform_device *pdev)
blk_queue_physical_block_size(disk->queue, 4096);
blk_queue_logical_block_size(disk->queue, 4096);
- add_disk(disk);
+ err = add_disk(disk);
+ if (err)
+ goto out_cleanup_disk;
pr_info("n64cart: %u kb disk\n", size / 1024);
return 0;
+
+out_cleanup_disk:
+ blk_cleanup_disk(disk);
+out:
+ return err;
}
static struct platform_driver n64cart_driver = {