On Fri, Apr 18, 2008 at 10:44:14AM +0530, Aneesh Kumar K.V wrote:
Updated one.
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index 28b5ada..572d809 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -2223,7 +2223,7 @@ static noinline void ext4_mb_store_history(struct ext4_allocation_context *ac)
static int ext4_mb_init_backend(struct super_block *sb)
{
- ext4_group_t i;
+ long i; /* should be able to store group number */
int j, len, metalen;
struct ext4_sb_info *sbi = EXT4_SB(sb);
int num_meta_group_infos =
@@ -2257,6 +2257,7 @@ static int ext4_mb_init_backend(struct super_block *sb)
if (meta_group_info == NULL) {
printk(KERN_ERR "EXT4-fs: can't allocate mem for a "
"buddy group\n");
+ i--;
goto err_freemeta;
}
sbi->s_group_info[i] = meta_group_info;
@@ -2328,10 +2329,12 @@ err_freebuddy:
kfree(ext4_get_group_info(sb, i));
i--;
}
- i = num_meta_group_infos;
+ i = num_meta_group_infos - 1;
err_freemeta:
- while (--i >= 0)
+ while (i >= 0) {
kfree(sbi->s_group_info[i]);
+ i--;
+ }
iput(sbi->s_buddy_cache);
err_freesgi:
kfree(sbi->s_group_info);
--