diff options
author | Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> | 2009-07-17 09:01:04 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2009-07-17 09:01:04 -0400 |
commit | 024eab4d5bf7e3168a2b71038b3e04e6b1f376ed (patch) | |
tree | 1a588b519826ce0adde9c539e34154abcd2d156e /fs | |
parent | ab86e5765d41a5eb4239a1c04d613db87bea5ed8 (diff) |
ext4: Fix memory leak fix when mounting an ext4 filesystem
The allocation of the ext4_group_info array was moved to a new
function ext4_mb_add_group_info() in commit 5f21b0e6 so that online
resize would use a common (and correct) codepath. Unfortunately, the
call to the new ext4_mb_add_group_info() function was added without
removing the code which originally allocated the array. This caused a
memory leak each time an ext4 filesystem was mounted.
The fix is simple; remove the code that did the original allocation,
since it is no longer needed.
Reported-by: Catalin Marinas <catalin.marinas@arm.com>
Tested-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/ext4/mballoc.c | 19 |
1 files changed, 0 insertions, 19 deletions
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index cd258463e2a9..cf9972090ad9 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c | |||
@@ -2571,13 +2571,11 @@ static int ext4_mb_init_backend(struct super_block *sb) | |||
2571 | { | 2571 | { |
2572 | ext4_group_t ngroups = ext4_get_groups_count(sb); | 2572 | ext4_group_t ngroups = ext4_get_groups_count(sb); |
2573 | ext4_group_t i; | 2573 | ext4_group_t i; |
2574 | int metalen; | ||
2575 | struct ext4_sb_info *sbi = EXT4_SB(sb); | 2574 | struct ext4_sb_info *sbi = EXT4_SB(sb); |
2576 | struct ext4_super_block *es = sbi->s_es; | 2575 | struct ext4_super_block *es = sbi->s_es; |
2577 | int num_meta_group_infos; | 2576 | int num_meta_group_infos; |
2578 | int num_meta_group_infos_max; | 2577 | int num_meta_group_infos_max; |
2579 | int array_size; | 2578 | int array_size; |
2580 | struct ext4_group_info **meta_group_info; | ||
2581 | struct ext4_group_desc *desc; | 2579 | struct ext4_group_desc *desc; |
2582 | 2580 | ||
2583 | /* This is the number of blocks used by GDT */ | 2581 | /* This is the number of blocks used by GDT */ |
@@ -2622,22 +2620,6 @@ static int ext4_mb_init_backend(struct super_block *sb) | |||
2622 | goto err_freesgi; | 2620 | goto err_freesgi; |
2623 | } | 2621 | } |
2624 | EXT4_I(sbi->s_buddy_cache)->i_disksize = 0; | 2622 | EXT4_I(sbi->s_buddy_cache)->i_disksize = 0; |
2625 | |||
2626 | metalen = sizeof(*meta_group_info) << EXT4_DESC_PER_BLOCK_BITS(sb); | ||
2627 | for (i = 0; i < num_meta_group_infos; i++) { | ||
2628 | if ((i + 1) == num_meta_group_infos) | ||
2629 | metalen = sizeof(*meta_group_info) * | ||
2630 | (ngroups - | ||
2631 | (i << EXT4_DESC_PER_BLOCK_BITS(sb))); | ||
2632 | meta_group_info = kmalloc(metalen, GFP_KERNEL); | ||
2633 | if (meta_group_info == NULL) { | ||
2634 | printk(KERN_ERR "EXT4-fs: can't allocate mem for a " | ||
2635 | "buddy group\n"); | ||
2636 | goto err_freemeta; | ||
2637 | } | ||
2638 | sbi->s_group_info[i] = meta_group_info; | ||
2639 | } | ||
2640 | |||
2641 | for (i = 0; i < ngroups; i++) { | 2623 | for (i = 0; i < ngroups; i++) { |
2642 | desc = ext4_get_group_desc(sb, i, NULL); | 2624 | desc = ext4_get_group_desc(sb, i, NULL); |
2643 | if (desc == NULL) { | 2625 | if (desc == NULL) { |
@@ -2655,7 +2637,6 @@ err_freebuddy: | |||
2655 | while (i-- > 0) | 2637 | while (i-- > 0) |
2656 | kfree(ext4_get_group_info(sb, i)); | 2638 | kfree(ext4_get_group_info(sb, i)); |
2657 | i = num_meta_group_infos; | 2639 | i = num_meta_group_infos; |
2658 | err_freemeta: | ||
2659 | while (i-- > 0) | 2640 | while (i-- > 0) |
2660 | kfree(sbi->s_group_info[i]); | 2641 | kfree(sbi->s_group_info[i]); |
2661 | iput(sbi->s_buddy_cache); | 2642 | iput(sbi->s_buddy_cache); |