Skip to content

Commit

Permalink
ext4: Free resources in some error path in ext4_fill_super
Browse files Browse the repository at this point in the history
Some of the error path in ext4_fill_super don't release the
resouces properly. So this patch just try to release them
in the right way.

Signed-off-by: Tao Ma <boyu.mt@taobao.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
  • Loading branch information
Tao Ma authored and Theodore Ts'o committed Oct 6, 2011
1 parent 7aa0bae commit dcf2d80
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions fs/ext4/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -3785,22 +3785,19 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
if (err) {
ext4_msg(sb, KERN_ERR, "failed to initialize mballoc (%d)",
err);
goto failed_mount4;
goto failed_mount5;
}

err = ext4_register_li_request(sb, first_not_zeroed);
if (err)
goto failed_mount4;
goto failed_mount6;

sbi->s_kobj.kset = ext4_kset;
init_completion(&sbi->s_kobj_unregister);
err = kobject_init_and_add(&sbi->s_kobj, &ext4_ktype, NULL,
"%s", sb->s_id);
if (err) {
ext4_mb_release(sb);
ext4_ext_release(sb);
goto failed_mount4;
};
if (err)
goto failed_mount7;

EXT4_SB(sb)->s_mount_state |= EXT4_ORPHAN_FS;
ext4_orphan_cleanup(sb, es);
Expand Down Expand Up @@ -3834,13 +3831,19 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
ext4_msg(sb, KERN_ERR, "VFS: Can't find ext4 filesystem");
goto failed_mount;

failed_mount7:
ext4_unregister_li_request(sb);
failed_mount6:
ext4_ext_release(sb);
failed_mount5:
ext4_mb_release(sb);
ext4_release_system_zone(sb);
failed_mount4:
iput(root);
sb->s_root = NULL;
ext4_msg(sb, KERN_ERR, "mount failed");
destroy_workqueue(EXT4_SB(sb)->dio_unwritten_wq);
failed_mount_wq:
ext4_release_system_zone(sb);
if (sbi->s_journal) {
jbd2_journal_destroy(sbi->s_journal);
sbi->s_journal = NULL;
Expand Down

0 comments on commit dcf2d80

Please sign in to comment.