Commit cee63f57 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] d_alloc_root() fixes: romfs

 - inode leak on d_alloc_root() failure
 - sanitized the cleanup logics
parent a828f4fd
...@@ -115,6 +115,7 @@ static int romfs_fill_super(struct super_block *s, void *data, int silent) ...@@ -115,6 +115,7 @@ static int romfs_fill_super(struct super_block *s, void *data, int silent)
{ {
struct buffer_head *bh; struct buffer_head *bh;
struct romfs_super_block *rsb; struct romfs_super_block *rsb;
struct inode *root;
int sz; int sz;
/* I would parse the options here, but there are none.. :) */ /* 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) ...@@ -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) strnlen(rsb->name, ROMFS_MAXFN) + 1 + ROMFH_PAD)
& ROMFH_MASK; & ROMFH_MASK;
brelse(bh);
s->s_op = &romfs_ops; s->s_op = &romfs_ops;
root = iget(s, sz);
if (!root)
goto out;
s->s_root = d_alloc_root(iget(s, sz)); s->s_root = d_alloc_root(iget(s, sz));
if (!s->s_root) if (!s->s_root)
goto outnobh; goto outiput;
/* Ehrhm; sorry.. :) And thanks to Hans-Joachim Widmaier :) */ brelse(bh);
if (0) { return 0;
outiput:
iput(root);
out: out:
brelse(bh); brelse(bh);
outnobh: outnobh:
return -EINVAL; return -EINVAL;
}
return 0;
} }
/* That's simple too. */ /* That's simple too. */
......
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