linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Xiao Ni <xni@redhat.com>
To: linux-raid@vger.kernel.org
Cc: jes sorensen <jes.sorensen@redhat.com>
Subject: Re: [PATCH] Memory leak once alloc superblock page failed
Date: Mon, 25 Aug 2014 03:45:57 -0400 (EDT)	[thread overview]
Message-ID: <905376206.27916256.1408952757621.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <1408500480-15200-1-git-send-email-xni@redhat.com>


Sorry for this patch. I find the memory will be released in the function bitmap_free
which is called in error path of bitmap_create.

The patch is wrong.

Best Regards
Xiao

----- Original Message -----
> From: "Xiao Ni" <xni@redhat.com>
> To: linux-raid@vger.kernel.org
> Cc: "jes sorensen" <jes.sorensen@redhat.com>, "Xiao Ni" <xni@redhat.com>
> Sent: Wednesday, August 20, 2014 10:08:00 AM
> Subject: [PATCH] Memory leak once alloc superblock page failed
> 
> [PATCH] Fix memory leak if alloc superblock page fails
> 
> Signed-off-by: Xiao Ni <xni@redhat.com>
> ---
>  drivers/md/bitmap.c |    5 ++++-
>  1 files changed, 4 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
> index 67f8b31..5997c34 100644
> --- a/drivers/md/bitmap.c
> +++ b/drivers/md/bitmap.c
> @@ -698,8 +698,11 @@ static int bitmap_storage_alloc(struct bitmap_storage
> *store,
>  
>  	if (with_super && !store->sb_page) {
>  		store->sb_page = alloc_page(GFP_KERNEL|__GFP_ZERO);
> -		if (store->sb_page == NULL)
> +		if (store->sb_page == NULL) {
> +			kfree(store->filemap);
> +			store->filemap = NULL;
>  			return -ENOMEM;
> +		}
>  		store->sb_page->index = 0;
>  	}
>  	pnum = 0;
> --
> 1.7.1
> 
> 

           reply	other threads:[~2014-08-25  7:45 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <1408500480-15200-1-git-send-email-xni@redhat.com>]

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=905376206.27916256.1408952757621.JavaMail.zimbra@redhat.com \
    --to=xni@redhat.com \
    --cc=jes.sorensen@redhat.com \
    --cc=linux-raid@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;
as well as URLs for NNTP newsgroup(s).