Commit 75c5a52d authored by Jan Kara's avatar Jan Kara Committed by Linus Torvalds

vfs: Allocate anon_inode_inode in anon_inode_init()

Currently we allocated anon_inode_inode in anon_inodefs_mount. This is
somewhat fragile as if that function ever gets called again, it will
overwrite anon_inode_inode pointer. So move the initialization of
anon_inode_inode to anon_inode_init().
Signed-off-by: default avatarJan Kara <jack@suse.cz>
[ Further simplified on suggestion from Dave Jones ]
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent f217c44e
...@@ -41,19 +41,8 @@ static const struct dentry_operations anon_inodefs_dentry_operations = { ...@@ -41,19 +41,8 @@ static const struct dentry_operations anon_inodefs_dentry_operations = {
static struct dentry *anon_inodefs_mount(struct file_system_type *fs_type, static struct dentry *anon_inodefs_mount(struct file_system_type *fs_type,
int flags, const char *dev_name, void *data) int flags, const char *dev_name, void *data)
{ {
struct dentry *root; return mount_pseudo(fs_type, "anon_inode:", NULL,
root = mount_pseudo(fs_type, "anon_inode:", NULL,
&anon_inodefs_dentry_operations, ANON_INODE_FS_MAGIC); &anon_inodefs_dentry_operations, ANON_INODE_FS_MAGIC);
if (!IS_ERR(root)) {
struct super_block *s = root->d_sb;
anon_inode_inode = alloc_anon_inode(s);
if (IS_ERR(anon_inode_inode)) {
dput(root);
deactivate_locked_super(s);
root = ERR_CAST(anon_inode_inode);
}
}
return root;
} }
static struct file_system_type anon_inode_fs_type = { static struct file_system_type anon_inode_fs_type = {
...@@ -175,18 +164,15 @@ EXPORT_SYMBOL_GPL(anon_inode_getfd); ...@@ -175,18 +164,15 @@ EXPORT_SYMBOL_GPL(anon_inode_getfd);
static int __init anon_inode_init(void) static int __init anon_inode_init(void)
{ {
int error;
anon_inode_mnt = kern_mount(&anon_inode_fs_type); anon_inode_mnt = kern_mount(&anon_inode_fs_type);
if (IS_ERR(anon_inode_mnt)) { if (IS_ERR(anon_inode_mnt))
error = PTR_ERR(anon_inode_mnt); panic("anon_inode_init() kernel mount failed (%ld)\n", PTR_ERR(anon_inode_mnt));
goto err_unregister_filesystem;
}
return 0;
err_unregister_filesystem: anon_inode_inode = alloc_anon_inode(anon_inode_mnt->mnt_sb);
unregister_filesystem(&anon_inode_fs_type); if (IS_ERR(anon_inode_inode))
panic(KERN_ERR "anon_inode_init() failed (%d)\n", error); panic("anon_inode_init() inode allocation failed (%ld)\n", PTR_ERR(anon_inode_inode));
return 0;
} }
fs_initcall(anon_inode_init); fs_initcall(anon_inode_init);
......
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