[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1636014799-20156-3-git-send-email-wubo40@huawei.com>
Date: Thu, 4 Nov 2021 16:33:19 +0800
From: Wu Bo <wubo40@...wei.com>
To: <axboe@...nel.dk>
CC: <linux-block@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<linfeilong@...wei.com>, <wubo40@...wei.com>
Subject: [PATCH 2/2] z2ram: add error handling support for add_disk()
We never checked for errors on add_disk() as this function
returned void. Now that is fixed.
So add error handling support for add_disk().
Signed-off-by: Wu Bo <wubo40@...wei.com>
---
drivers/block/z2ram.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/block/z2ram.c b/drivers/block/z2ram.c
index 4eef218..822df1d 100644
--- a/drivers/block/z2ram.c
+++ b/drivers/block/z2ram.c
@@ -318,6 +318,7 @@ static void z2_release(struct gendisk *disk, fmode_t mode)
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,11 @@ 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)
--
1.8.3.1
Powered by blists - more mailing lists