Commit 7573737d authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] d_alloc_root() fixes: cramfs

 - inode leak on d_alloc_root() failure
 - unchecked result of d_alloc_root() leading to oops in fs/super.c
parent bf30ba74
......@@ -199,6 +199,7 @@ static int cramfs_fill_super(struct super_block *sb, void *data, int silent)
struct cramfs_super super;
unsigned long root_offset;
struct cramfs_sb_info *sbi;
struct inode *root;
sbi = kmalloc(sizeof(struct cramfs_sb_info), GFP_KERNEL);
if (!sbi)
......@@ -263,7 +264,14 @@ static int cramfs_fill_super(struct super_block *sb, void *data, int silent)
/* Set it all up.. */
sb->s_op = &cramfs_ops;
sb->s_root = d_alloc_root(get_cramfs_inode(sb, &super.root));
root = get_cramfs_inode(sb, &super.root);
if (!root)
goto out;
sb->s_root = d_alloc_root(root);
if (!sb->s_root) {
iput(root);
goto out;
}
return 0;
out:
kfree(sbi);
......
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