[PATCH] Fix ext2_new_inode() failure paths
authorChris Sykes <chris@sigsegv.plus.com>
Wed, 28 Sep 2005 04:45:22 +0000 (21:45 -0700)
committerLinus Torvalds <torvalds@g5.osdl.org>
Wed, 28 Sep 2005 14:46:40 +0000 (07:46 -0700)
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>
fs/ext2/ialloc.c

index c8d07030c89725c8b4451287b867a4ba637065a3..e2d6208633a737eea56ea50083c8f1e4c3559695 100644 (file)
@@ -605,27 +605,28 @@ got:
        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);