Commit faf08523 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] d_alloc_root() fixes: ext3

 - inode leak on d_alloc_root() failure
parent c02d9d1f
...@@ -1040,6 +1040,7 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent) ...@@ -1040,6 +1040,7 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
unsigned long offset = 0; unsigned long offset = 0;
unsigned long journal_inum = 0; unsigned long journal_inum = 0;
unsigned long def_mount_opts; unsigned long def_mount_opts;
struct inode *root;
int blocksize; int blocksize;
int hblock; int hblock;
int db_count; int db_count;
...@@ -1354,16 +1355,17 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent) ...@@ -1354,16 +1355,17 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
* so we can safely mount the rest of the filesystem now. * so we can safely mount the rest of the filesystem now.
*/ */
sb->s_root = d_alloc_root(iget(sb, EXT3_ROOT_INO)); root = iget(sb, EXT3_ROOT_INO);
if (!sb->s_root || !S_ISDIR(sb->s_root->d_inode->i_mode) || sb->s_root = d_alloc_root(root);
!sb->s_root->d_inode->i_blocks || !sb->s_root->d_inode->i_size) { if (!sb->s_root) {
if (sb->s_root) { printk(KERN_ERR "EXT3-fs: get root inode failed\n");
dput(sb->s_root); iput(root);
sb->s_root = NULL; goto failed_mount3;
printk(KERN_ERR }
"EXT3-fs: corrupt root inode, run e2fsck\n"); if (!S_ISDIR(root->i_mode) || !root->i_blocks || !root->i_size) {
} else dput(sb->s_root);
printk(KERN_ERR "EXT3-fs: get root inode failed\n"); sb->s_root = NULL;
printk(KERN_ERR "EXT3-fs: corrupt root inode, run e2fsck\n");
goto failed_mount3; goto failed_mount3;
} }
......
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