From cee63f57e3b69fd1ec9f520c69bb160ad104094e Mon Sep 17 00:00:00 2001 From: Alexander Viro Date: Wed, 3 Mar 2004 21:23:34 -0800 Subject: [PATCH] [PATCH] d_alloc_root() fixes: romfs - inode leak on d_alloc_root() failure - sanitized the cleanup logics --- fs/romfs/inode.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/fs/romfs/inode.c b/fs/romfs/inode.c index 80b17af9bb0d3..5d04b8bf6b573 100644 --- a/fs/romfs/inode.c +++ b/fs/romfs/inode.c @@ -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. */ -- 2.53.0