Skip to content

Commit

Permalink
[PATCH] Fix ext2_new_inode() failure paths
Browse files Browse the repository at this point in the history
Fix failure paths in ext2_new_inode() and clean up duplicated code: -
DQUOT_DROP() was not being called if ext2_init_security() failed.

Signed-off-by: Chris Sykes <chris@sigsegv.plus.com>
Cc: Stephen Smalley <sds@epoch.ncsc.mil>
Cc: Jan Kara <jack@ucw.cz>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
Chris Sykes authored and Linus Torvalds committed Sep 28, 2005
1 parent ee4e527 commit 9ed6c2f
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions fs/ext2/ialloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -605,27 +605,28 @@ struct inode *ext2_new_inode(struct inode *dir, int mode)
insert_inode_hash(inode);

if (DQUOT_ALLOC_INODE(inode)) {
DQUOT_DROP(inode);
err = -ENOSPC;
goto fail2;
goto fail_drop;
}

err = ext2_init_acl(inode, dir);
if (err) {
DQUOT_FREE_INODE(inode);
DQUOT_DROP(inode);
goto fail2;
}
if (err)
goto fail_free_drop;

err = ext2_init_security(inode,dir);
if (err) {
DQUOT_FREE_INODE(inode);
goto fail2;
}
if (err)
goto fail_free_drop;

mark_inode_dirty(inode);
ext2_debug("allocating inode %lu\n", inode->i_ino);
ext2_preread_inode(inode);
return inode;

fail2:
fail_free_drop:
DQUOT_FREE_INODE(inode);

fail_drop:
DQUOT_DROP(inode);
inode->i_flags |= S_NOQUOTA;
inode->i_nlink = 0;
iput(inode);
Expand Down

0 comments on commit 9ed6c2f

Please sign in to comment.