public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Arne Jansen <sensille@gmx.net>
To: Jesper Juhl <jj@chaosbits.net>
Cc: Chris Mason <chris.mason@oracle.com>,
	linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] btrfs: Don't leak mem in scrub_fixup().
Date: Mon, 07 Nov 2011 10:24:50 +0100	[thread overview]
Message-ID: <4EB7A3E2.2060400@gmx.net> (raw)
In-Reply-To: <alpine.LNX.2.00.1111062331350.5763@swampdragon.chaosbits.net>

On 06.11.2011 23:33, Jesper Juhl wrote:
> It seems to me that we may leak the memory allocated to 'multi' in
> scrub_fixup() if, for example, 'length' turns out to be less than
> PAGE_SIZE after we call btrfs_map_block(). This patch should take care
> of the leak by always kfree'ing 'multi' before we return in that error
> case.

Thanks for looking into this. The current pull request already contains
a fix for this, from Ilya Dryomov.

-Arne

> 
> Signed-off-by: Jesper Juhl <jj@chaosbits.net>
> ---
>  fs/btrfs/scrub.c |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)
> 
>  Compile tested only since I don't have any btrfs filesystems to test on.
> 
> diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
> index a8d03d5..b53433e 100644
> --- a/fs/btrfs/scrub.c
> +++ b/fs/btrfs/scrub.c
> @@ -271,6 +271,7 @@ static void scrub_fixup(struct scrub_bio *sbio, int ix)
>  	ret = btrfs_map_block(map_tree, REQ_WRITE, logical, &length,
>  			      &multi, 0);
>  	if (ret || !multi || length < PAGE_SIZE) {
> +		kfree(multi);
>  		printk(KERN_ERR
>  		       "scrub_fixup: btrfs_map_block failed us for %llu\n",
>  		       (unsigned long long)logical);


      reply	other threads:[~2011-11-07  9:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-06 22:33 [PATCH] btrfs: Don't leak mem in scrub_fixup() Jesper Juhl
2011-11-07  9:24 ` Arne Jansen [this message]

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=4EB7A3E2.2060400@gmx.net \
    --to=sensille@gmx.net \
    --cc=chris.mason@oracle.com \
    --cc=jj@chaosbits.net \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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