]> git.neil.brown.name Git - history.git/commitdiff
[PATCH] d_alloc_root() fixes: romfs
authorAlexander Viro <viro@www.linux.org.uk>
Thu, 4 Mar 2004 05:23:34 +0000 (21:23 -0800)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Thu, 4 Mar 2004 05:23:34 +0000 (21:23 -0800)
 - inode leak on d_alloc_root() failure
 - sanitized the cleanup logics

fs/romfs/inode.c

index 80b17af9bb0d33deb3c1ea368883ea820d9f53dd..5d04b8bf6b573e5e432e8867994931d7567d3a01 100644 (file)
@@ -115,6 +115,7 @@ static int romfs_fill_super(struct super_block *s, void *data, int silent)
 {
        struct buffer_head *bh;
        struct romfs_super_block *rsb;
+       struct inode *root;
        int sz;
 
        /* I would parse the options here, but there are none.. :) */
@@ -154,23 +155,25 @@ static int romfs_fill_super(struct super_block *s, void *data, int silent)
              strnlen(rsb->name, ROMFS_MAXFN) + 1 + ROMFH_PAD)
             & ROMFH_MASK;
 
-       brelse(bh);
-
        s->s_op = &romfs_ops;
+       root = iget(s, sz);
+       if (!root)
+               goto out;
+
        s->s_root = d_alloc_root(iget(s, sz));
 
        if (!s->s_root)
-               goto outnobh;
+               goto outiput;
 
-       /* Ehrhm; sorry.. :)  And thanks to Hans-Joachim Widmaier  :) */
-       if (0) {
+       brelse(bh);
+       return 0;
+
+outiput:
+       iput(root);
 out:
-               brelse(bh);
+       brelse(bh);
 outnobh:
-               return -EINVAL;
-       }
-
-       return 0;
+       return -EINVAL;
 }
 
 /* That's simple too. */