ext4: grow the s_group_info array as needed
[firefly-linux-kernel-4.4.55.git] / fs / ext4 / resize.c
index 3f5c67bf13a2157474d2003f51925f740a360700..f288933bf4c0af1f40c256995d72faee052796c2 100644 (file)
@@ -1507,6 +1507,10 @@ int ext4_group_add(struct super_block *sb, struct ext4_new_group_data *input)
        if (err)
                return err;
 
+       err = ext4_mb_alloc_groupinfo(sb, input->group + 1);
+       if (err)
+               goto out;
+
        flex_gd.count = 1;
        flex_gd.groups = input;
        flex_gd.bg_flags = &bg_flags;
@@ -1732,6 +1736,10 @@ int ext4_resize_fs(struct super_block *sb, ext4_fsblk_t n_blocks_count)
        if (err)
                return err;
 
+       err = ext4_mb_alloc_groupinfo(sb, n_group + 1);
+       if (err)
+               goto out;
+
        flex_gd = alloc_flex_gd(flexbg_size);
        if (flex_gd == NULL) {
                err = -ENOMEM;