Commit 32a9bb57 authored by Manish Katiyar's avatar Manish Katiyar Committed by Theodore Ts'o

ext4: fix missing iput of root inode for some mount error paths

This assures that the root inode is not leaked, and that sb->s_root is
NULL, which will prevent generic_shutdown_super() from doing extra
work, including call sync_filesystem, which ultimately results in
ext4_sync_fs() getting called with an uninitialized struct super,
which is the cause of the crash noted in Kernel Bugzilla #26752.

https://bugzilla.kernel.org/show_bug.cgi?id=26752Signed-off-by: default avatarManish Katiyar <mkatiyar@gmail.com>
Signed-off-by: default avatar"Theodore Ts'o" <tytso@mit.edu>
parent 6d9c85eb
...@@ -3521,17 +3521,16 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) ...@@ -3521,17 +3521,16 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
if (IS_ERR(root)) { if (IS_ERR(root)) {
ext4_msg(sb, KERN_ERR, "get root inode failed"); ext4_msg(sb, KERN_ERR, "get root inode failed");
ret = PTR_ERR(root); ret = PTR_ERR(root);
root = NULL;
goto failed_mount4; goto failed_mount4;
} }
if (!S_ISDIR(root->i_mode) || !root->i_blocks || !root->i_size) { if (!S_ISDIR(root->i_mode) || !root->i_blocks || !root->i_size) {
iput(root);
ext4_msg(sb, KERN_ERR, "corrupt root inode, run e2fsck"); ext4_msg(sb, KERN_ERR, "corrupt root inode, run e2fsck");
goto failed_mount4; goto failed_mount4;
} }
sb->s_root = d_alloc_root(root); sb->s_root = d_alloc_root(root);
if (!sb->s_root) { if (!sb->s_root) {
ext4_msg(sb, KERN_ERR, "get root dentry failed"); ext4_msg(sb, KERN_ERR, "get root dentry failed");
iput(root);
ret = -ENOMEM; ret = -ENOMEM;
goto failed_mount4; goto failed_mount4;
} }
...@@ -3647,6 +3646,8 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) ...@@ -3647,6 +3646,8 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
goto failed_mount; goto failed_mount;
failed_mount4: failed_mount4:
iput(root);
sb->s_root = NULL;
ext4_msg(sb, KERN_ERR, "mount failed"); ext4_msg(sb, KERN_ERR, "mount failed");
destroy_workqueue(EXT4_SB(sb)->dio_unwritten_wq); destroy_workqueue(EXT4_SB(sb)->dio_unwritten_wq);
failed_mount_wq: failed_mount_wq:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment