summaryrefslogtreecommitdiff
path: root/fs/ext4
diff options
context:
space:
mode:
authorYu Jian <yujian@whamcloud.com>2011-08-01 17:41:46 -0400
committerTheodore Ts'o <tytso@mit.edu>2011-08-01 17:41:46 -0400
commit79a77c5ac34cc27ccbfbdf7113b41cdd93534eab (patch)
tree0217516fde94d1dea524ee4f40279cc03fc5cefa /fs/ext4
parent48e6061bf4bb25eec151b91f22fd90a5b9a4920a (diff)
downloadlinux-3.10-79a77c5ac34cc27ccbfbdf7113b41cdd93534eab.tar.gz
linux-3.10-79a77c5ac34cc27ccbfbdf7113b41cdd93534eab.tar.bz2
linux-3.10-79a77c5ac34cc27ccbfbdf7113b41cdd93534eab.zip
ext4: prevent memory leaks from ext4_mb_init_backend() on error path
In ext4_mb_init(), if the s_locality_group allocation fails it will currently cause the allocations made in ext4_mb_init_backend() to be leaked. Moving the ext4_mb_init_backend() allocation after the s_locality_group allocation avoids that problem. Signed-off-by: Yu Jian <yujian@whamcloud.com> Signed-off-by: Andreas Dilger <adilger@whamcloud.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext4')
-rw-r--r--fs/ext4/mballoc.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index e41620b56e5..17a5a57c415 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -2465,12 +2465,6 @@ int ext4_mb_init(struct super_block *sb, int needs_recovery)
i++;
} while (i <= sb->s_blocksize_bits + 1);
- /* init file for buddy data */
- ret = ext4_mb_init_backend(sb);
- if (ret != 0) {
- goto out;
- }
-
spin_lock_init(&sbi->s_md_lock);
spin_lock_init(&sbi->s_bal_lock);
@@ -2507,6 +2501,12 @@ int ext4_mb_init(struct super_block *sb, int needs_recovery)
spin_lock_init(&lg->lg_prealloc_lock);
}
+ /* init file for buddy data */
+ ret = ext4_mb_init_backend(sb);
+ if (ret != 0) {
+ goto out;
+ }
+
if (sbi->s_proc)
proc_create_data("mb_groups", S_IRUGO, sbi->s_proc,
&ext4_mb_seq_groups_fops, sb);