From patchwork Wed Aug 8 19:27:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Edwards X-Patchwork-Id: 10560471 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 3FDFE139A for ; Wed, 8 Aug 2018 19:28:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2F9BE2AED1 for ; Wed, 8 Aug 2018 19:28:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 23DDF2AEDE; Wed, 8 Aug 2018 19:28:31 +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,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 BA2682AED1 for ; Wed, 8 Aug 2018 19:28:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728233AbeHHVth (ORCPT ); Wed, 8 Aug 2018 17:49:37 -0400 Received: from legacy.ddn.com ([64.47.133.206]:8510 "EHLO legacy.ddn.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727295AbeHHVth (ORCPT ); Wed, 8 Aug 2018 17:49:37 -0400 Received: from LAX-EX-CAHT3.datadirect.datadirectnet.com (10.8.103.85) by LAX-EX-CAHT3.datadirect.datadirectnet.com (10.8.103.85) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Wed, 8 Aug 2018 12:28:28 -0700 Received: from LAX-EX-CAHT1.datadirect.datadirectnet.com (10.8.103.81) by LAX-EX-CAHT3.datadirect.datadirectnet.com (10.8.103.85) with Microsoft SMTP Server (TLS) id 15.0.1367.3 via Frontend Transport; Wed, 8 Aug 2018 12:28:28 -0700 Received: from psuche.datadirect.datadirectnet.com (10.48.114.46) by LAX-EX-CAHT1.datadirect.datadirectnet.com (10.8.103.81) with Microsoft SMTP Server (TLS) id 14.3.389.1; Wed, 8 Aug 2018 12:28:28 -0700 From: Greg Edwards To: CC: Jens Axboe , Christoph Hellwig , Greg Edwards Subject: [PATCH] block: bvec_nr_vecs() returns value for wrong slab Date: Wed, 8 Aug 2018 13:27:53 -0600 Message-ID: <20180808192753.817-1-gedwards@ddn.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Originating-IP: [10.48.114.46] 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 In commit ed996a52c868 ("block: simplify and cleanup bvec pool handling"), the value of the slab index is incremented by one in bvec_alloc() after the allocation is done to indicate an index value of 0 does not need to be later freed. bvec_nr_vecs() was not updated accordingly, and thus returns the wrong value. Decrement idx before performing the lookup. Fixes: ed996a52c868 ("block: simplify and cleanup bvec pool handling") Signed-off-by: Greg Edwards --- block/bio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/bio.c b/block/bio.c index 047c5dca6d90..ff94640bc734 100644 --- a/block/bio.c +++ b/block/bio.c @@ -156,7 +156,7 @@ static void bio_put_slab(struct bio_set *bs) unsigned int bvec_nr_vecs(unsigned short idx) { - return bvec_slabs[idx].nr_vecs; + return bvec_slabs[--idx].nr_vecs; } void bvec_free(mempool_t *pool, struct bio_vec *bv, unsigned int idx)