| From b94ab13e6409f51707fe29273b7659d9096eb41c Mon Sep 17 00:00:00 2001 |
| From: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> |
| Date: Fri, 17 Jul 2009 09:01:04 -0400 |
| Subject: [PATCH 01/85] ext4: Fix memory leak fix when mounting an ext4 filesystem |
| |
| (cherry picked from commit 024eab4d5bf7e3168a2b71038b3e04e6b1f376ed) |
| |
| 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> |
| Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> |
| --- |
| fs/ext4/mballoc.c | 19 ------------------- |
| 1 file changed, 19 deletions(-) |
| |
| --- a/fs/ext4/mballoc.c |
| +++ b/fs/ext4/mballoc.c |
| @@ -2571,13 +2571,11 @@ static int ext4_mb_init_backend(struct s |
| { |
| ext4_group_t ngroups = ext4_get_groups_count(sb); |
| ext4_group_t i; |
| - int metalen; |
| struct ext4_sb_info *sbi = EXT4_SB(sb); |
| struct ext4_super_block *es = sbi->s_es; |
| int num_meta_group_infos; |
| int num_meta_group_infos_max; |
| int array_size; |
| - struct ext4_group_info **meta_group_info; |
| struct ext4_group_desc *desc; |
| |
| /* This is the number of blocks used by GDT */ |
| @@ -2622,22 +2620,6 @@ static int ext4_mb_init_backend(struct s |
| goto err_freesgi; |
| } |
| EXT4_I(sbi->s_buddy_cache)->i_disksize = 0; |
| - |
| - metalen = sizeof(*meta_group_info) << EXT4_DESC_PER_BLOCK_BITS(sb); |
| - for (i = 0; i < num_meta_group_infos; i++) { |
| - if ((i + 1) == num_meta_group_infos) |
| - metalen = sizeof(*meta_group_info) * |
| - (ngroups - |
| - (i << EXT4_DESC_PER_BLOCK_BITS(sb))); |
| - meta_group_info = kmalloc(metalen, GFP_KERNEL); |
| - if (meta_group_info == NULL) { |
| - printk(KERN_ERR "EXT4-fs: can't allocate mem for a " |
| - "buddy group\n"); |
| - goto err_freemeta; |
| - } |
| - sbi->s_group_info[i] = meta_group_info; |
| - } |
| - |
| for (i = 0; i < ngroups; i++) { |
| desc = ext4_get_group_desc(sb, i, NULL); |
| if (desc == NULL) { |
| @@ -2655,7 +2637,6 @@ err_freebuddy: |
| while (i-- > 0) |
| kfree(ext4_get_group_info(sb, i)); |
| i = num_meta_group_infos; |
| -err_freemeta: |
| while (i-- > 0) |
| kfree(sbi->s_group_info[i]); |
| iput(sbi->s_buddy_cache); |