linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: NeilBrown <neilb@suse.de>
To: majianpeng <majianpeng@gmail.com>
Cc: linux-raid <linux-raid@vger.kernel.org>
Subject: Re: [PATCH] md/raid10:Memleak fix if allocate rep1_bio failed in function want_replacement().
Date: Tue, 17 Apr 2012 13:09:38 +1000	[thread overview]
Message-ID: <20120417130938.248d885a@notabene.brown> (raw)
In-Reply-To: <201204161924086710486@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1670 bytes --]

On Mon, 16 Apr 2012 19:24:13 +0800 "majianpeng" <majianpeng@gmail.com> wrote:

> >From cb391c87d24a32b211d9f0a9df942987bf8e0ac4 Mon Sep 17 00:00:00 2001
> From: majianpeng <majianpeng@gmail.com>
> Date: Mon, 16 Apr 2012 19:19:53 +0800
> Subject: [PATCH] md/raid10:Memleak fix if allocate rep1_bio failed in
>  function want_replacement().
>  Reported by kmemleak.

Please try to make the description a bit easier to read.
The first line should be a brief summary of the problem or fix.

Details come afterwards.

I have change it to the following and applied.

Thanks,
NeilBrown

    md/raid10: Fix memleak in r10buf_pool_alloc
    
    If the allocation of rep1_bio fails, we currently don't free the 'bio'
    of the same dev.
    
    Reported by kmemleak.
    
    Signed-off-by: majianpeng <majianpeng@gmail.com>
    Signed-off-by: NeilBrown <neilb@suse.de>



> 
> Signed-off-by: majianpeng <majianpeng@gmail.com>
> ---
>  drivers/md/raid10.c |    7 ++++---
>  1 files changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
> index c8dbb84..19e9af1 100644
> --- a/drivers/md/raid10.c
> +++ b/drivers/md/raid10.c
> @@ -165,10 +165,11 @@ out_free_pages:
>  	while (j--)
>  		for (i = 0; i < RESYNC_PAGES ; i++)
>  			safe_put_page(r10_bio->devs[j].bio->bi_io_vec[i].bv_page);
> -	j = -1;
> +	j = 0;
>  out_free_bio:
> -	while (++j < nalloc) {
> -		bio_put(r10_bio->devs[j].bio);
> +	for ( ; j < nalloc; j++) {
> +		if (r10_bio->devs[j].bio)
> +			bio_put(r10_bio->devs[j].bio);
>  		if (r10_bio->devs[j].repl_bio)
>  			bio_put(r10_bio->devs[j].repl_bio);
>  	}


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 828 bytes --]

      reply	other threads:[~2012-04-17  3:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-16 11:24 [PATCH] md/raid10:Memleak fix if allocate rep1_bio failed in function want_replacement() majianpeng
2012-04-17  3:09 ` NeilBrown [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=20120417130938.248d885a@notabene.brown \
    --to=neilb@suse.de \
    --cc=linux-raid@vger.kernel.org \
    --cc=majianpeng@gmail.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;
as well as URLs for NNTP newsgroup(s).