From: Minfei Huang <mnfhuang@gmail.com>
To: Minfei Huang <mhuang@redhat.com>
Cc: axboe@fb.com, m@bjorling.me, akinobu.mita@gmail.com,
rusty@rustcorp.com.au, keith.busch@intel.com, mcgrof@suse.com,
krinkin.m.u@gmail.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] null_blk: Fix error path in module initialization
Date: Tue, 8 Dec 2015 20:35:43 +0800 [thread overview]
Message-ID: <20151208121453.GA94282@dhcp-128-22.nay.redhat.com> (raw)
In-Reply-To: <1448545693-22141-1-git-send-email-mhuang@redhat.com>
Ping.
Any comment is appreciate.
Thanks
Minfei
On 11/26/15 at 09:48P, Minfei Huang wrote:
> From: Minfei Huang <mnfhuang@gmail.com>
>
> Module couldn't release resource properly during the initialization. To
> fix this issue, we will clean up the proper resource before returning.
>
> Signed-off-by: Minfei Huang <mnfhuang@gmail.com>
> ---
> drivers/block/null_blk.c | 24 +++++++++++++++++-------
> 1 file changed, 17 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/block/null_blk.c b/drivers/block/null_blk.c
> index 5c8ba54..ec99568 100644
> --- a/drivers/block/null_blk.c
> +++ b/drivers/block/null_blk.c
> @@ -780,7 +780,9 @@ out:
>
> static int __init null_init(void)
> {
> + int ret = 0;
> unsigned int i;
> + struct nullb *nullb;
>
> if (bs > PAGE_SIZE) {
> pr_warn("null_blk: invalid block size\n");
> @@ -835,22 +837,30 @@ static int __init null_init(void)
> 0, 0, NULL);
> if (!ppa_cache) {
> pr_err("null_blk: unable to create ppa cache\n");
> - return -ENOMEM;
> + ret = -ENOMEM;
> + goto err_ppa;
> }
> }
>
> for (i = 0; i < nr_devices; i++) {
> - if (null_add_dev()) {
> - unregister_blkdev(null_major, "nullb");
> - goto err_ppa;
> - }
> + ret = null_add_dev();
> + if (ret)
> + goto err_dev;
> }
>
> pr_info("null: module loaded\n");
> return 0;
> +
> +err_dev:
> + while (!list_empty(&nullb_list)) {
> + nullb = list_entry(nullb_list.next, struct nullb, list);
> + null_del_dev(nullb);
> + }
> + if (use_lightnvm)
> + kmem_cache_destroy(ppa_cache);
> err_ppa:
> - kmem_cache_destroy(ppa_cache);
> - return -EINVAL;
> + unregister_blkdev(null_major, "nullb");
> + return ret;
> }
>
> static void __exit null_exit(void)
> --
> 1.8.3.1
>
next prev parent reply other threads:[~2015-12-08 12:35 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-26 13:48 Minfei Huang
2015-12-08 12:35 ` Minfei Huang [this message]
2015-12-08 20:48 ` Jens Axboe
2015-12-09 4:20 ` Minfei Huang
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=20151208121453.GA94282@dhcp-128-22.nay.redhat.com \
--to=mnfhuang@gmail.com \
--cc=akinobu.mita@gmail.com \
--cc=axboe@fb.com \
--cc=keith.busch@intel.com \
--cc=krinkin.m.u@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=m@bjorling.me \
--cc=mcgrof@suse.com \
--cc=mhuang@redhat.com \
--cc=rusty@rustcorp.com.au \
/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®