From: Rakesh Pandit <rakesh@tuxera.com>
To: "Matias Bjørling" <mb@lightnvm.io>,
linux-block@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: "Javier González" <jg@lightnvm.io>
Subject: [PATCH 6/6] lightnvm: pblk: fix releases of kmem cache in error path
Date: Sun, 1 Oct 2017 16:26:35 +0300 [thread overview]
Message-ID: <20171001132633.GA5783@hercules.tuxera.com> (raw)
If pblk_core_init fails lets destroy all global caches.
Signed-off-by: Rakesh Pandit <rakesh@tuxera.com>
---
drivers/lightnvm/pblk-init.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/lightnvm/pblk-init.c b/drivers/lightnvm/pblk-init.c
index 519e5cf..9f39800 100644
--- a/drivers/lightnvm/pblk-init.c
+++ b/drivers/lightnvm/pblk-init.c
@@ -246,7 +246,7 @@ static int pblk_core_init(struct pblk *pblk)
pblk->page_bio_pool = mempool_create_page_pool(nvm_max_phys_sects(dev),
0);
if (!pblk->page_bio_pool)
- return -ENOMEM;
+ goto free_global_caches;
pblk->gen_ws_pool = mempool_create_slab_pool(PBLK_GEN_WS_POOL_SIZE,
pblk_ws_cache);
@@ -314,6 +314,12 @@ static int pblk_core_init(struct pblk *pblk)
mempool_destroy(pblk->gen_ws_pool);
free_page_bio_pool:
mempool_destroy(pblk->page_bio_pool);
+free_global_caches:
+ kmem_cache_destroy(pblk_ws_cache);
+ kmem_cache_destroy(pblk_rec_cache);
+ kmem_cache_destroy(pblk_g_rq_cache);
+ kmem_cache_destroy(pblk_e_rq_cache);
+ kmem_cache_destroy(pblk_w_rq_cache);
return -ENOMEM;
}
--
2.7.4
next reply other threads:[~2017-10-01 13:26 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-01 13:26 Rakesh Pandit [this message]
2017-10-02 12:44 ` Javier González
2017-10-02 17:21 ` Rakesh Pandit
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=20171001132633.GA5783@hercules.tuxera.com \
--to=rakesh@tuxera.com \
--cc=jg@lightnvm.io \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mb@lightnvm.io \
/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
Powered by JetHome