On Fri, Aug 19, 2011 at 11:28:08PM +0800, Tao Ma wrote: > From: Tao Ma <boyu.mt@xxxxxxxxxx> > > 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@xxxxxxxxxx> 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 -- To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html