Commit d6042eac authored by Al Viro's avatar Al Viro Committed by Linus Torvalds

minixfs: misplaced checks lead to dentry leak

bitmap size sanity checks should be done *before* allocating ->s_root;
there their cleanup on failure would be correct.  As it is, we do iput()
on root inode, but leak the root dentry...
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
Acked-by: default avatarJosh Boyer <jwboyer@redhat.com>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 8a88951b
...@@ -263,23 +263,6 @@ static int minix_fill_super(struct super_block *s, void *data, int silent) ...@@ -263,23 +263,6 @@ static int minix_fill_super(struct super_block *s, void *data, int silent)
goto out_no_root; goto out_no_root;
} }
ret = -ENOMEM;
s->s_root = d_alloc_root(root_inode);
if (!s->s_root)
goto out_iput;
if (!(s->s_flags & MS_RDONLY)) {
if (sbi->s_version != MINIX_V3) /* s_state is now out from V3 sb */
ms->s_state &= ~MINIX_VALID_FS;
mark_buffer_dirty(bh);
}
if (!(sbi->s_mount_state & MINIX_VALID_FS))
printk("MINIX-fs: mounting unchecked file system, "
"running fsck is recommended\n");
else if (sbi->s_mount_state & MINIX_ERROR_FS)
printk("MINIX-fs: mounting file system with errors, "
"running fsck is recommended\n");
/* Apparently minix can create filesystems that allocate more blocks for /* Apparently minix can create filesystems that allocate more blocks for
* the bitmaps than needed. We simply ignore that, but verify it didn't * the bitmaps than needed. We simply ignore that, but verify it didn't
* create one with not enough blocks and bail out if so. * create one with not enough blocks and bail out if so.
...@@ -300,6 +283,23 @@ static int minix_fill_super(struct super_block *s, void *data, int silent) ...@@ -300,6 +283,23 @@ static int minix_fill_super(struct super_block *s, void *data, int silent)
goto out_iput; goto out_iput;
} }
ret = -ENOMEM;
s->s_root = d_alloc_root(root_inode);
if (!s->s_root)
goto out_iput;
if (!(s->s_flags & MS_RDONLY)) {
if (sbi->s_version != MINIX_V3) /* s_state is now out from V3 sb */
ms->s_state &= ~MINIX_VALID_FS;
mark_buffer_dirty(bh);
}
if (!(sbi->s_mount_state & MINIX_VALID_FS))
printk("MINIX-fs: mounting unchecked file system, "
"running fsck is recommended\n");
else if (sbi->s_mount_state & MINIX_ERROR_FS)
printk("MINIX-fs: mounting file system with errors, "
"running fsck is recommended\n");
return 0; return 0;
out_iput: out_iput:
......
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