From: Ted Ts'o <tytso@mit.edu>
To: Tao Ma <tm@tao.ma>
Cc: linux-ext4@vger.kernel.org
Subject: Re: [PATCH] ext4: Free resources in the error path of ext4_mb_init.
Date: Thu, 6 Oct 2011 10:22:20 -0400 [thread overview]
Message-ID: <20111006142220.GA19049@thunk.org> (raw)
In-Reply-To: <1313767689-2786-1-git-send-email-tm@tao.ma>
On Fri, Aug 19, 2011 at 11:28:08PM +0800, Tao Ma wrote:
> From: Tao Ma <boyu.mt@taobao.com>
>
> In commit 79a77c5ac, we move ext4_mb_init_backend after the allocation
> of s_locality_group to avoid memory leak in error path, but there are
> still some other error paths in ext4_mb_init that need to do the same
> work. So this patch adds all the error patch for ext4_mb_init. And all
> the pointers are reset to NULL in case the caller may double free them.
>
> Signed-off-by: Tao Ma <boyu.mt@taobao.com>
but I had to reorder the cleanup code for
"out_free_groupinfo_slab" and "out_free_locality_groups" in the
following patch hunk....
> @@ -2513,11 +2512,19 @@ int ext4_mb_init(struct super_block *sb, int needs_recovery)
>
> if (sbi->s_journal)
> sbi->s_journal->j_commit_callback = release_blocks_on_commit;
> +
> + return 0;
> +
> +out_free_groupinfo_slab:
> + ext4_groupinfo_destroy_slabs();
> +out_free_locality_groups:
> + free_percpu(sbi->s_locality_groups);
> + sbi->s_locality_groups = NULL;
Since we first allocate the groupinfo slabs, and then the locality
groups, so the cleanup paths need to do things in the opposite
order.
- Ted
next prev parent reply other threads:[~2011-10-06 15:58 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-19 15:28 [PATCH] ext4: Free resources in the error path of ext4_mb_init Tao Ma
2011-08-19 15:28 ` [PATCH] ext4: Free resources in some error path in ext4_fill_super Tao Ma
2011-10-06 15:58 ` Ted Ts'o
2011-10-06 14:22 ` Ted Ts'o [this message]
2011-10-07 15:07 ` [PATCH v2] ext4: Free resources in the error path of ext4_mb_init Tao Ma
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=20111006142220.GA19049@thunk.org \
--to=tytso@mit.edu \
--cc=linux-ext4@vger.kernel.org \
--cc=tm@tao.ma \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.