aboutsummaryrefslogtreecommitdiffstats
path: root/fs/minix
diff options
context:
space:
mode:
authorAl Viro <viro@ZenIV.linux.org.uk>2012-01-04 05:51:03 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2012-01-04 18:03:06 -0500
commitd6042eac44b54dc5c7cb839175eb51dfd03d7633 (patch)
treeb2a1c5878771f4d7a5aada868bdbc7eafc4eba3b /fs/minix
parent8a88951b5878dc475dcd841cefc767e36397d14e (diff)
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: Al Viro <viro@zeniv.linux.org.uk> Acked-by: Josh Boyer <jwboyer@redhat.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/minix')
-rw-r--r--fs/minix/inode.c34
1 files changed, 17 insertions, 17 deletions
diff --git a/fs/minix/inode.c b/fs/minix/inode.c
index 1d9e33966db0..4d46a6a59070 100644
--- a/fs/minix/inode.c
+++ b/fs/minix/inode.c
@@ -263,23 +263,6 @@ static int minix_fill_super(struct super_block *s, void *data, int silent)
263 goto out_no_root; 263 goto out_no_root;
264 } 264 }
265 265
266 ret = -ENOMEM;
267 s->s_root = d_alloc_root(root_inode);
268 if (!s->s_root)
269 goto out_iput;
270
271 if (!(s->s_flags & MS_RDONLY)) {
272 if (sbi->s_version != MINIX_V3) /* s_state is now out from V3 sb */
273 ms->s_state &= ~MINIX_VALID_FS;
274 mark_buffer_dirty(bh);
275 }
276 if (!(sbi->s_mount_state & MINIX_VALID_FS))
277 printk("MINIX-fs: mounting unchecked file system, "
278 "running fsck is recommended\n");
279 else if (sbi->s_mount_state & MINIX_ERROR_FS)
280 printk("MINIX-fs: mounting file system with errors, "
281 "running fsck is recommended\n");
282
283 /* Apparently minix can create filesystems that allocate more blocks for 266 /* Apparently minix can create filesystems that allocate more blocks for
284 * the bitmaps than needed. We simply ignore that, but verify it didn't 267 * the bitmaps than needed. We simply ignore that, but verify it didn't
285 * create one with not enough blocks and bail out if so. 268 * 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 goto out_iput; 283 goto out_iput;
301 } 284 }
302 285
286 ret = -ENOMEM;
287 s->s_root = d_alloc_root(root_inode);
288 if (!s->s_root)
289 goto out_iput;
290
291 if (!(s->s_flags & MS_RDONLY)) {
292 if (sbi->s_version != MINIX_V3) /* s_state is now out from V3 sb */
293 ms->s_state &= ~MINIX_VALID_FS;
294 mark_buffer_dirty(bh);
295 }
296 if (!(sbi->s_mount_state & MINIX_VALID_FS))
297 printk("MINIX-fs: mounting unchecked file system, "
298 "running fsck is recommended\n");
299 else if (sbi->s_mount_state & MINIX_ERROR_FS)
300 printk("MINIX-fs: mounting file system with errors, "
301 "running fsck is recommended\n");
302
303 return 0; 303 return 0;
304 304
305out_iput: 305out_iput: