From patchwork Sun Oct 1 13:26:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rakesh Pandit X-Patchwork-Id: 9979721 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 798CA60365 for ; Sun, 1 Oct 2017 13:26:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7A27F28A13 for ; Sun, 1 Oct 2017 13:26:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6F0FB28AFA; Sun, 1 Oct 2017 13:26:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EEA5728A13 for ; Sun, 1 Oct 2017 13:26:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751140AbdJAN0h (ORCPT ); Sun, 1 Oct 2017 09:26:37 -0400 Received: from mx1.mpynet.fi ([82.197.21.84]:25536 "EHLO mx1.mpynet.fi" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751118AbdJAN0h (ORCPT ); Sun, 1 Oct 2017 09:26:37 -0400 Date: Sun, 1 Oct 2017 16:26:35 +0300 From: Rakesh Pandit To: Matias =?iso-8859-1?Q?Bj=F8rling?= , , CC: Javier =?iso-8859-1?Q?Gonz=E1lez?= Subject: [PATCH 6/6] lightnvm: pblk: fix releases of kmem cache in error path Message-ID: <20171001132633.GA5783@hercules.tuxera.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.8.0 (2017-02-23) X-ClientProxiedBy: tuxera-exch.ad.tuxera.com (10.20.48.11) To tuxera-exch.ad.tuxera.com (10.20.48.11) Received-SPF: none Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If pblk_core_init fails lets destroy all global caches. Signed-off-by: Rakesh Pandit --- 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; }