summaryrefslogtreecommitdiffstats
path: root/drivers/block
diff options
context:
space:
mode:
authorLuis Chamberlain <mcgrof@kernel.org>2021-11-04 00:04:30 +0100
committerJens Axboe <axboe@kernel.dk>2021-11-04 12:48:50 +0100
commit15733754ccf35c49d2f36a7ac51adc8b975c1c78 (patch)
tree8aa762fe566cc53327453f95df3b9112fe6d52d9 /drivers/block
parentnvdimm/pmem: use add_disk() error handling (diff)
downloadlinux-15733754ccf35c49d2f36a7ac51adc8b975c1c78.tar.xz
linux-15733754ccf35c49d2f36a7ac51adc8b975c1c78.zip
z2ram: 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. Only the disk is cleaned up inside z2ram_register_disk() as the caller deals with the rest. Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Luis Chamberlain <mcgrof@kernel.org> Link: https://lore.kernel.org/r/20211103230437.1639990-8-mcgrof@kernel.org Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'drivers/block')
-rw-r--r--drivers/block/z2ram.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/block/z2ram.c b/drivers/block/z2ram.c
index 4eef218108c6..ccc52c935faf 100644
--- a/drivers/block/z2ram.c
+++ b/drivers/block/z2ram.c
@@ -318,6 +318,7 @@ static const struct blk_mq_ops z2_mq_ops = {
static int z2ram_register_disk(int minor)
{
struct gendisk *disk;
+ int err;
disk = blk_mq_alloc_disk(&tag_set, NULL);
if (IS_ERR(disk))
@@ -333,8 +334,10 @@ static int z2ram_register_disk(int minor)
sprintf(disk->disk_name, "z2ram");
z2ram_gendisk[minor] = disk;
- add_disk(disk);
- return 0;
+ err = add_disk(disk);
+ if (err)
+ blk_cleanup_disk(disk);
+ return err;
}
static int __init z2_init(void)