Return-Path: Received: from mail-bl2nam02on0115.outbound.protection.outlook.com ([104.47.38.115]:14976 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727843AbeH3WOX (ORCPT ); Thu, 30 Aug 2018 18:14:23 -0400 From: Sasha Levin To: "stable@vger.kernel.org" CC: Greg Edwards , Jens Axboe , Sasha Levin Subject: [PATCH AUTOSEL 4.14 39/67] block: bvec_nr_vecs() returns value for wrong slab Date: Thu, 30 Aug 2018 18:10:59 +0000 Message-ID: <20180830180918.36327-39-alexander.levin@microsoft.com> References: <20180830180918.36327-1-alexander.levin@microsoft.com> In-Reply-To: <20180830180918.36327-1-alexander.levin@microsoft.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: From: Greg Edwards [ Upstream commit d6c02a9beb67f13d5f14f23e72fa9981e8b84477 ] 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 Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- block/bio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/bio.c b/block/bio.c index 194d28cdc642..2e5d881423b8 100644 --- a/block/bio.c +++ b/block/bio.c @@ -156,7 +156,7 @@ static void bio_put_slab(struct bio_set *bs) =20 unsigned int bvec_nr_vecs(unsigned short idx) { - return bvec_slabs[idx].nr_vecs; + return bvec_slabs[--idx].nr_vecs; } =20 void bvec_free(mempool_t *pool, struct bio_vec *bv, unsigned int idx) --=20 2.17.1