Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932247AbbLRP3G (ORCPT ); Fri, 18 Dec 2015 10:29:06 -0500 Received: from mail-pf0-f180.google.com ([209.85.192.180]:35730 "EHLO mail-pf0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751592AbbLRP3D (ORCPT ); Fri, 18 Dec 2015 10:29:03 -0500 Date: Fri, 18 Dec 2015 23:29:04 +0800 From: Minfei Huang To: axboe@kernel.dk Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, mhuang@redhat.com Subject: Re: [PATCH 2/2] bio: Free own bvec before assigning the source bio's bvec Message-ID: <20151218152904.GA19027@dhcp-129-201.nay.redhat.com> References: <1450450952-18565-1-git-send-email-mnfhuang@gmail.com> <1450450952-18565-2-git-send-email-mnfhuang@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1450450952-18565-2-git-send-email-mnfhuang@gmail.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1455 Lines: 49 Sorry to bother you, since I have missed the nr_iovecs in bio_clone_fast. Nacked this patch. Thanks Minfei On 12/18/15 at 11:02P, Minfei Huang wrote: > This is a memory leaking during splitting the bio by the caller > bio_clone_fast. > > Clone bio may allocate its own bvec, if demanding bvec is more than > inline bvec in function bio_alloc_bioset. > > bi_io_vec is assigned to the source bio's bvec directly without freeing > it firstly in function __bio_clone_fast. > > To fix it, freeing the own bvec firstly before assigning the source > bio's bvec. > > Signed-off-by: Minfei Huang > --- > block/bio.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/block/bio.c b/block/bio.c > index 70d9814..b24fd6e 100644 > --- a/block/bio.c > +++ b/block/bio.c > @@ -581,6 +581,10 @@ void __bio_clone_fast(struct bio *bio, struct bio *bio_src) > bio_set_flag(bio, BIO_CLONED); > bio->bi_rw = bio_src->bi_rw; > bio->bi_iter = bio_src->bi_iter; > + > + if (bio_flagged(bio, BIO_OWNS_VEC)) > + bvec_free(bio->bi_pool->bvec_pool, > + bio->bi_io_vec, BIO_POOL_IDX(bio)); > bio->bi_io_vec = bio_src->bi_io_vec; > } > EXPORT_SYMBOL(__bio_clone_fast); > -- > 2.6.3 > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/