From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0C6CBC19F2D for ; Wed, 27 Jul 2022 17:00:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240633AbiG0RAB (ORCPT ); Wed, 27 Jul 2022 13:00:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230173AbiG0Q6v (ORCPT ); Wed, 27 Jul 2022 12:58:51 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D60C6759F; Wed, 27 Jul 2022 09:37:02 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 06B11B821A6; Wed, 27 Jul 2022 16:36:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 494D2C433D6; Wed, 27 Jul 2022 16:36:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658939785; bh=TRUEB7p4AbyqXNIiq6XMX+D4eko7r6zTCXx7Ibqm4S4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ip0nrFGvVOJjmq0MHmqJx8FmkV9ZrdvzconIDUXKST4UjOyP6HD6xfzlkxOuNlh6h Vgey0YKOMb44wVN7US4JiiGiQJVaJfe4ewTTEN+4ZUvh+YWI9aMa//LOuCmX527mM+ wA5iNEcOTw+uCfia3F90R4uJtztbZzbpx1z/DLNM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Johannes Thumshirn , Chaitanya Kulkarni , Damien Le Moal , Christoph Hellwig , Ming Lei , Jens Axboe Subject: [PATCH 5.10 104/105] block: fix memory leak of bvec Date: Wed, 27 Jul 2022 18:11:30 +0200 Message-Id: <20220727161016.275605431@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161012.056867467@linuxfoundation.org> References: <20220727161012.056867467@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ming Lei commit 8358c28a5d44bf0223a55a2334086c3707bb4185 upstream. bio_init() clears bio instance, so the bvec index has to be set after bio_init(), otherwise bio->bi_io_vec may be leaked. Fixes: 3175199ab0ac ("block: split bio_kmalloc from bio_alloc_bioset") Cc: Johannes Thumshirn Cc: Chaitanya Kulkarni Cc: Damien Le Moal Reviewed-by: Christoph Hellwig Signed-off-by: Ming Lei Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- block/bio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/block/bio.c +++ b/block/bio.c @@ -491,8 +491,8 @@ struct bio *bio_alloc_bioset(gfp_t gfp_m if (unlikely(!bvl)) goto err_free; - bio->bi_flags |= idx << BVEC_POOL_OFFSET; bio_init(bio, bvl, bvec_nr_vecs(idx)); + bio->bi_flags |= idx << BVEC_POOL_OFFSET; } else if (nr_iovecs) { bio_init(bio, bio->bi_inline_vecs, BIO_INLINE_VECS); } else {