From: Wu Bo <wubo40@huawei.com>
To: <axboe@kernel.dk>
Cc: <linux-block@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<linfeilong@huawei.com>, <wubo40@huawei.com>
Subject: [PATCH 2/2] z2ram: add error handling support for add_disk()
Date: Thu, 4 Nov 2021 16:33:19 +0800 [thread overview]
Message-ID: <1636014799-20156-3-git-send-email-wubo40@huawei.com> (raw)
In-Reply-To: <1636014799-20156-1-git-send-email-wubo40@huawei.com>
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@huawei.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
next prev parent reply other threads:[~2021-11-04 8:01 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-04 8:33 [PATCH 0/2] " Wu Bo
2021-11-04 8:33 ` [PATCH 1/2] brd: " Wu Bo
2021-11-04 8:33 ` Wu Bo [this message]
2021-11-04 8:45 ` [PATCH 0/2] " Christoph Hellwig
2021-11-05 2:06 ` Wu Bo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1636014799-20156-3-git-send-email-wubo40@huawei.com \
--to=wubo40@huawei.com \
--cc=axboe@kernel.dk \
--cc=linfeilong@huawei.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®