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)
{
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. */
......
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