From: Li Zefan <lizf@cn.fujitsu.com>
To: Jens Axboe <jens.axboe@oracle.com>
Cc: LKML <linux-kernel@vger.kernel.org>, martin.petersen@oracle.com
Subject: Re: [PATCH] block: fix memory leak in bio_clone()
Date: Mon, 09 Mar 2009 17:34:50 +0800 [thread overview]
Message-ID: <49B4E2BA.3030809@cn.fujitsu.com> (raw)
In-Reply-To: <20090309092407.GI11787@kernel.dk>
Jens Axboe wrote:
> On Mon, Mar 09 2009, Li Zefan wrote:
>> If bio_integrity_clone() fails, bio_clone() returns NULL without freeing
>> the newly allocated bio.
>>
>> Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
>> ---
>> fs/bio.c | 4 +++-
>> 1 files changed, 3 insertions(+), 1 deletions(-)
>>
>> diff --git a/fs/bio.c b/fs/bio.c
>> index 124b95c..896330e 100644
>> --- a/fs/bio.c
>> +++ b/fs/bio.c
>> @@ -465,8 +465,10 @@ struct bio *bio_clone(struct bio *bio, gfp_t gfp_mask)
>>
>> ret = bio_integrity_clone(b, bio, fs_bio_set);
>>
>> - if (ret < 0)
>> + if (ret < 0) {
>> + bio_put(bio);
>> return NULL;
>> + }
>> }
>>
>> return b;
>> -- 1.5.4.rc3
>
> Good spotting. But it looks like there are actually several problems
> there. bio_integrity_clone() is mempool backed. Currently that ret < 0
> can never trigger, since bio_integrity_clone() has hard-wired __GFP_WAIT
Do you mean GFP_NOIO?
> as the mempool mask. So the leak will not occur, but it does mean that
> it isn't honoring the gfp_mask passed in to bio_clone(), which is the
I noticed there was a patch to do this, and seems you planed to merge
it into .29?
"[PATCH] Add gfp_mask to bio_integrity_clone()"
http://lkml.org/lkml/2008/10/30/11
> first bug. The second bug is that it should be using its own bioset, as
> it is illegal to do multiple __GFP_WAIT allocations on a single mempool
> and always expect progress.
>
next prev parent reply other threads:[~2009-03-09 9:35 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-09 9:13 [PATCH] block: fix memory leak in bio_clone() Li Zefan
2009-03-09 9:21 ` Li Zefan
2009-03-09 9:24 ` Jens Axboe
2009-03-09 9:34 ` Li Zefan [this message]
2009-03-09 9:38 ` Jens Axboe
2009-03-09 9:51 ` Li Zefan
2009-03-09 9:54 ` Jens Axboe
2009-03-09 16:10 ` Martin K. Petersen
2009-03-09 19:21 ` Jens Axboe
2009-03-10 3:42 ` Martin K. Petersen
2009-03-10 7:29 ` Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=49B4E2BA.3030809@cn.fujitsu.com \
--to=lizf@cn.fujitsu.com \
--cc=jens.axboe@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=martin.petersen@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox