From patchwork Mon May 28 08:58:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matias Bjorling X-Patchwork-Id: 10430155 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 622F960249 for ; Mon, 28 May 2018 09:04:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 544B428BDB for ; Mon, 28 May 2018 09:04:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4866B28BE1; Mon, 28 May 2018 09:04:16 +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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=unavailable 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 CFCDA28BDB for ; Mon, 28 May 2018 09:04:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754372AbeE1JCy (ORCPT ); Mon, 28 May 2018 05:02:54 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:55351 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754143AbeE1I7K (ORCPT ); Mon, 28 May 2018 04:59:10 -0400 Received: by mail-wm0-f67.google.com with SMTP id a8-v6so30125989wmg.5 for ; Mon, 28 May 2018 01:59:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lightnvm-io.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=F8a11Omr1nmBsfBGo6FYNv9+oOqlGVF5zUl43Fl6Jkk=; b=T7WINWusGiSQaR6gBn60Mq2ruW8TLjcsWTFjN2d8ZrsERw5P+8YxFMogH0yerfTYbZ WQIWU3RwMmvmbO3nSlQYyh2Dk32+gOaBgkddhu/XvPiMwom2agu8Tzbg9Yc6WsZnfgfW 7diaB5DHs0e1+wxMfvaigwFcxSVzgzlp8nF6zd8BzTqi4YpC/SOVgqEn7rxJrzIGvBhU ObJZO3hRnSW02ms7TmRUPXDqAKvDKXHbNYZKzwajgGvclN5J7WfWMjlS/ibNSpwSjNQv RZJxObdR8SfYzE1uV3G6rJeGfQ0NO71HCZ74Ja7NlKPqSahyHB9rQDhwdLj9Oz9UbxjV n5WQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=F8a11Omr1nmBsfBGo6FYNv9+oOqlGVF5zUl43Fl6Jkk=; b=dyDBgFYBWbIfVF+cdBCup8VqIQYlYPBzqiIqiZSv7uxegEIsTE1imas5kT+DM0LAjo d90ldWGNjiqsQLBdm0Ah47Bc+ZauvSRke/cHYSA4Hg6lYLTA6tHaPhCsjbYeYS1gtZ0+ XFazzBaOG9uMREta9QwuqghIh+bfMwOhtBywa4VA2A4CowqHCBjDIrLiI42jjqbBstew d0Y5r2aZPt8ddFDxk2255qWO13fMmaMKEPYgwepEgedutsrnGw3bAgE+XN710Yme6h/H 5Xw+5bwhoD6reHGULOBRUC/YvQGy2gZuGHK49kqC6I0/6YLr8AYEAaPbh20zU5e6VAXZ yIHw== X-Gm-Message-State: ALKqPwfQV1nn9LPvLBq1UX3ntXBtjfOdHoYaC9I6pZV2ebMa0JX4pSHY JyrNHHbu/10kGgf3J7NonJUi7g== X-Google-Smtp-Source: ADUXVKJOFQzcOHSICKtdrC9exh76q6U+MMWz+0+bGT3p5AWkSBEwUid/FUZo5LvNluWahLvejhOlyQ== X-Received: by 2002:a2e:89d7:: with SMTP id c23-v6mr7923595ljk.22.1527497949000; Mon, 28 May 2018 01:59:09 -0700 (PDT) Received: from Macroninja.cnexlabs.com (95-166-82-66-cable.dk.customer.tdc.net. [95.166.82.66]) by smtp.gmail.com with ESMTPSA id u2-v6sm5777848lji.4.2018.05.28.01.59.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 May 2018 01:59:08 -0700 (PDT) From: =?UTF-8?q?Matias=20Bj=C3=B8rling?= To: axboe@fb.com Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Igor Konopko , Marcin Dziegielewski , =?UTF-8?q?Matias=20Bj=C3=B8rling?= Subject: [GIT PULL 15/20] lightnvm: proper error handling for pblk_bio_add_pages Date: Mon, 28 May 2018 10:58:36 +0200 Message-Id: <20180528085841.26684-16-mb@lightnvm.io> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180528085841.26684-1-mb@lightnvm.io> References: <20180528085841.26684-1-mb@lightnvm.io> MIME-Version: 1.0 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 From: Igor Konopko Currently in case of error caused by bio_pc_add_page in pblk_bio_add_pages two issues occur when calling from pblk_rb_read_to_bio(). First one is in pblk_bio_free_pages, since we are trying to free pages not allocated from our mempool. Second one is the warn from dma_pool_free, that we are trying to free NULL pointer dma. This commit fix both issues. Signed-off-by: Igor Konopko Signed-off-by: Marcin Dziegielewski Signed-off-by: Matias Bjørling --- drivers/lightnvm/pblk-core.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/lightnvm/pblk-core.c b/drivers/lightnvm/pblk-core.c index e43093e27084..a20b41c355c5 100644 --- a/drivers/lightnvm/pblk-core.c +++ b/drivers/lightnvm/pblk-core.c @@ -278,7 +278,9 @@ void pblk_free_rqd(struct pblk *pblk, struct nvm_rq *rqd, int type) return; } - nvm_dev_dma_free(dev->parent, rqd->meta_list, rqd->dma_meta_list); + if (rqd->meta_list) + nvm_dev_dma_free(dev->parent, rqd->meta_list, + rqd->dma_meta_list); mempool_free(rqd, pool); } @@ -316,7 +318,7 @@ int pblk_bio_add_pages(struct pblk *pblk, struct bio *bio, gfp_t flags, return 0; err: - pblk_bio_free_pages(pblk, bio, 0, i - 1); + pblk_bio_free_pages(pblk, bio, (bio->bi_vcnt - i), i); return -1; }