From patchwork Fri Jun 21 09:11:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matias Bjorling X-Patchwork-Id: 11008831 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DE0C26C5 for ; Fri, 21 Jun 2019 09:12:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CE539289DA for ; Fri, 21 Jun 2019 09:12:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C2932289E5; Fri, 21 Jun 2019 09:12:20 +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=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 60C54289DA for ; Fri, 21 Jun 2019 09:12:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726210AbfFUJMT (ORCPT ); Fri, 21 Jun 2019 05:12:19 -0400 Received: from mail-lf1-f67.google.com ([209.85.167.67]:38099 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726426AbfFUJML (ORCPT ); Fri, 21 Jun 2019 05:12:11 -0400 Received: by mail-lf1-f67.google.com with SMTP id b11so4515841lfa.5 for ; Fri, 21 Jun 2019 02:12: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=wGWPck9wpyZRR3E02z/BR5xB8SDUTdEAXPWir9EA+Iw=; b=w6zy5RcYtlwpn9uZXBTPnNqk13OWqgW/Z2IEW/b5Va7tVCdbZbgJ0Cnouiv1j8bK7K bWDV6rGP+wes+RvdAIhBg3cRGlsDMwzbX/6Pfp6zyqHpiYqTGnTFvLM0Pg65iaGyGe9S wL+Qtd2PN1OIZ6m+5zeoMcbz9V58AEbYH7Ozo007qVRWkc4c0o/JWGYAueBfZWH3kyVJ GiMfrOUImqgt+6PJ9Mmm3Q25GZAXsoP7p0h+TeEEOa9HMFuROrH4kUTSFef/409yBtpA SZksPiF4DLQ6yesYrrSClVK54ohgnvbcEUQAx3MFCpdpHzGuDwlT14kmhEqQv6OX076f LdMQ== 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=wGWPck9wpyZRR3E02z/BR5xB8SDUTdEAXPWir9EA+Iw=; b=Beru1fdCY3DE0VCn9FyCkHdkT6qBGehq4Fuli7HyNgHL34LFFIkszfc8+DX+eJnbpi wZdv/oQwB+8BouDrK9HjTM9RNGVEK7aca9Moj964Jfxomy86xOtwJGj4w9g6qYyX/5t8 Hi3WHFZDXkcCniBP3ro+Q6yg9/WuvG/H5pX1cbOvscx2ngWva8unUavV5kZ4WDdXhNpL iCBzpLBlK3UCXFergk16QmMFbNiRC1idLm2tdza1/rJNNJc0rXanFGl6V88g9eh8/38V pkjm3FhTQZszHSiQX9jrM1aQMMMahQUlBR68GPA9OdVig/dJ0jhgQDWfHnGDcH9kfG7a aipQ== X-Gm-Message-State: APjAAAUHePAXLBl+d/TnpjSwvmFhBKb5mVXjihdHuUh2G7W7CHzxxQZs eqR0zbQY0zlClDAXi0K8UQ9ElA== X-Google-Smtp-Source: APXvYqwEQaPtv/AT8pgQU9n75IZ6a1nGoS44tadH/5E9dMkzEJyY5mAnoUx0dj0rJvAXeL1ic/ruZA== X-Received: by 2002:a19:d5:: with SMTP id 204mr1954825lfa.66.1561108328971; Fri, 21 Jun 2019 02:12:08 -0700 (PDT) Received: from skyninja.webspeed.dk (2-111-91-225-cable.dk.customer.tdc.net. [2.111.91.225]) by smtp.gmail.com with ESMTPSA id z26sm303178ljz.64.2019.06.21.02.12.07 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 21 Jun 2019 02:12:08 -0700 (PDT) From: =?utf-8?q?Matias_Bj=C3=B8rling?= To: axboe@fb.com Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Heiner Litz , =?utf-8?q?Matias_Bj=C3=B8rling?= Subject: [GIT PULL 1/2] lightnvm: pblk: fix freeing of merged pages Date: Fri, 21 Jun 2019 11:11:59 +0200 Message-Id: <20190621091200.23168-2-mb@lightnvm.io> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190621091200.23168-1-mb@lightnvm.io> References: <20190621091200.23168-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: Heiner Litz bio_add_pc_page() may merge pages when a bio is padded due to a flush. Fix iteration over the bio to free the correct pages in case of a merge. Signed-off-by: Heiner Litz Reviewed-by: Javier González Signed-off-by: Matias Bjørling --- drivers/lightnvm/pblk-core.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/lightnvm/pblk-core.c b/drivers/lightnvm/pblk-core.c index 773537804319..f546e6f28b8a 100644 --- a/drivers/lightnvm/pblk-core.c +++ b/drivers/lightnvm/pblk-core.c @@ -323,14 +323,16 @@ void pblk_free_rqd(struct pblk *pblk, struct nvm_rq *rqd, int type) void pblk_bio_free_pages(struct pblk *pblk, struct bio *bio, int off, int nr_pages) { - struct bio_vec bv; - int i; + struct bio_vec *bv; + struct page *page; + int i, e, nbv = 0; - WARN_ON(off + nr_pages != bio->bi_vcnt); - - for (i = off; i < nr_pages + off; i++) { - bv = bio->bi_io_vec[i]; - mempool_free(bv.bv_page, &pblk->page_bio_pool); + for (i = 0; i < bio->bi_vcnt; i++) { + bv = &bio->bi_io_vec[i]; + page = bv->bv_page; + for (e = 0; e < bv->bv_len; e += PBLK_EXPOSED_PAGE_SIZE, nbv++) + if (nbv >= off) + mempool_free(page++, &pblk->page_bio_pool); } } From patchwork Fri Jun 21 09:12:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matias Bjorling X-Patchwork-Id: 11008829 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1287C6C5 for ; Fri, 21 Jun 2019 09:12:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 01855289DA for ; Fri, 21 Jun 2019 09:12:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E9E96289E5; Fri, 21 Jun 2019 09:12:18 +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=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 6473C289DA for ; Fri, 21 Jun 2019 09:12:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726494AbfFUJMN (ORCPT ); Fri, 21 Jun 2019 05:12:13 -0400 Received: from mail-lf1-f65.google.com ([209.85.167.65]:40635 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726045AbfFUJMM (ORCPT ); Fri, 21 Jun 2019 05:12:12 -0400 Received: by mail-lf1-f65.google.com with SMTP id a9so4504003lff.7 for ; Fri, 21 Jun 2019 02:12:11 -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=k4aXc+WCbb0KX3YXwP2LFgbpd81EOKzrd5cyRZaZTSg=; b=sSFnuYhsFN1JD56EIiE1pEfjm6C0QSyZG31411kwJRybXeYFh6pC5C8yQp22lVlwXe 0RZW82JsiuTifNXgpYfDvor7psQ1a+TZHnK57CSfKwGHg+AeqA4JmUZrBMhfnlvhPGET K5cisM7SCV5xW754YlV5rHRAgZN9L262ZefebDu/MTCz8ZLuXTwkkfmzCTXJTdXuO1Ub e6Bo+iqKVs6StBtV4THNiGApkGGzW/T9Bnkiacm15kj30YQfuNKOrQcErGQ8y1FS5OOa /xzpWU9gkb9vV2I8975rGq7NbVaO18XGeU6FmtFxgNTnIgzW5g/LSYuJzeYPkJrnCn75 py3g== 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=k4aXc+WCbb0KX3YXwP2LFgbpd81EOKzrd5cyRZaZTSg=; b=IFMlII8dC24KAhJojubpnr5ZgJka6i3ESCKU4AdrmKEBY6sNPjJSIknJ4u+hDhMuaO Qx4aO2/clC04In1xbKlYIVfzDyU6YPAjTmYP16hNiQhbQ4HIrkE6XDzNnqwnbCUIRUyW JA2z8sp6/8HYJ/factm2LqjU2/e1bv9tpuQl6/ubffUR2PR1mKsAkiv59RLNc1KeltHK OaokIOeX/x51PLfnVvfxa26ldL/499oIgOYmGpYNuLhoZBh+Agz4UEfOExx8zgO1i75S pu5vwUuej8H4ylxvB91LucVGCjo3lV7Ijrjv7xyHfCUTwJdF3hu8p3IuNUBJPWczODiT 8OoA== X-Gm-Message-State: APjAAAVMJTAw0ngaKjv6EjivbmaTjGrB/MRY7IR3G8DOKav/DOH3+fkO AKxxcO2gGehaf2lewVbrCPMIy1ny3Go= X-Google-Smtp-Source: APXvYqzvbOWqaN5hXsBK1NV7YAT9x6a/dav5F34bCxNcV082rL8AhKA+NiD88XxrJVwsEh/8uCeRfA== X-Received: by 2002:a05:6512:24a:: with SMTP id b10mr65728968lfo.37.1561108330334; Fri, 21 Jun 2019 02:12:10 -0700 (PDT) Received: from skyninja.webspeed.dk (2-111-91-225-cable.dk.customer.tdc.net. [2.111.91.225]) by smtp.gmail.com with ESMTPSA id z26sm303178ljz.64.2019.06.21.02.12.09 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 21 Jun 2019 02:12:09 -0700 (PDT) From: =?utf-8?q?Matias_Bj=C3=B8rling?= To: axboe@fb.com Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven , =?utf-8?q?Matias_Bj=C3=B8rling?= Subject: [GIT PULL 2/2] lightnvm: fix uninitialized pointer in nvm_remove_tgt() Date: Fri, 21 Jun 2019 11:12:00 +0200 Message-Id: <20190621091200.23168-3-mb@lightnvm.io> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190621091200.23168-1-mb@lightnvm.io> References: <20190621091200.23168-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: Geert Uytterhoeven With gcc 4.1: drivers/lightnvm/core.c: In function ‘nvm_remove_tgt’: drivers/lightnvm/core.c:510: warning: ‘t’ is used uninitialized in this function Indeed, if no NVM devices have been registered, t will be an uninitialized pointer, and may be dereferenced later. A call to nvm_remove_tgt() can be triggered from userspace by issuing the NVM_DEV_REMOVE ioctl on the lightnvm control device. Fix this by preinitializing t to NULL. Fixes: 843f2edbdde085b4 ("lightnvm: do not remove instance under global lock") Signed-off-by: Geert Uytterhoeven Signed-off-by: Matias Bjørling --- drivers/lightnvm/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c index 7d555b110ecd..a600934fdd9c 100644 --- a/drivers/lightnvm/core.c +++ b/drivers/lightnvm/core.c @@ -478,7 +478,7 @@ static void __nvm_remove_target(struct nvm_target *t, bool graceful) */ static int nvm_remove_tgt(struct nvm_ioctl_remove *remove) { - struct nvm_target *t; + struct nvm_target *t = NULL; struct nvm_dev *dev; down_read(&nvm_lock);